angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

"ng update" doesn't support private repos such as FontAwesome 5 Pro

Open bjornharvold opened this issue 8 years ago • 172 comments

Versions

Angular CLI: 6.0.0
Node: 9.11.1
OS: darwin x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Repro steps

  • Add dependency on a private repo such as FontAwesome 5 Pro
  • Run ng update @angular/core

Observed behavior

Not found : @fortawesome/pro-regular-svg-icons

Mention any other details that might be useful (optional)

This works fine using npm directly because the private repo has already been registered with npm

bjornharvold avatar May 04 '18 02:05 bjornharvold

@devoto13 I can't seem to find @angular/[email protected], it is not available in the npm registry: https://www.npmjs.com/package/@angular/cli

I was able to install @angular-devkit/[email protected] individually, but that still resulted in a 401 Unauthorized, but not sure if this is related.

abbazabacto avatar May 31 '18 20:05 abbazabacto

@abbazabacto It is @schematics/[email protected] package, which contains the fix. It is a dependency of @angular/cli and the last version of which depends on @schematics/[email protected].

@ajpierson It looks like there is no easy way to try it out at the moment and the easiest way, as you suggest, is to wait until @angular/[email protected] is released. Sorry for the confusion.

devoto13 avatar Jun 01 '18 07:06 devoto13

Thanks, that's how it looked to me too as free I dug in some more glad to hear I'm not crazy.

On Fri, Jun 1, 2018 at 1:54 AM Yaroslav Admin [email protected] wrote:

@abbazabacto https://github.com/abbazabacto It is @schematics/[email protected] package, which contains the fix. It is a dependency of @angular/cli and the last version depends on @schematics/[email protected].

@ajpierson https://github.com/ajpierson It looks like there is no easy way to try it out at the moment and the easiest way, as you suggest, is to wait until @angular/[email protected] is released. Sorry for the confusion.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/10624#issuecomment-393797741, or mute the thread https://github.com/notifications/unsubscribe-auth/AADcRWLfQ5m6zhLFo2ATQmhNa3C9KgCmks5t4PMZgaJpZM4TyC_f .

ajpierson avatar Jun 01 '18 09:06 ajpierson

We're using a private repository and get "error 401 unauthorized" (see #10704 which was closed as duplicate of this issue). The problem still exists with @angular/[email protected].


    "@angular/cli@^6.1.0-rc.0":  version "6.1.0-rc.0"

    resolved "https://registry.yarnpkg.com/@angular/cli/-/cli-6.1.0-rc.0.tgz#7ffb203ab429beca19003369647015aa707921b9"
    dependencies:
      "@angular-devkit/architect" "0.7.0-rc.0"
      "@angular-devkit/core" "0.7.0-rc.0"
      "@angular-devkit/schematics" "0.7.0-rc.0"
      "@schematics/angular" "0.7.0-rc.0"
      "@schematics/update" "0.7.0-rc.0"
      opn "^5.3.0"
      rxjs "^6.0.0"
      semver "^5.1.0"
      symbol-observable "^1.2.0"
      yargs-parser "^10.0.0"

cluetjen avatar Jun 17 '18 12:06 cluetjen

Issue still exists inside @angular/[email protected]

Brampage avatar Jun 21 '18 14:06 Brampage

I have the same issue with a private git+ssh dependency and trying this against the latest version on master:

Angular CLI: local (v6.1.0-beta.0, branch: master)
Node: 9.10.0
OS: darwin x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.0-rc.0
@angular-devkit/build-angular     0.7.0-rc.0
@angular-devkit/build-optimizer   0.7.0-rc.0
@angular-devkit/build-webpack     0.7.0-rc.0
@angular-devkit/core              0.7.0-rc.0
@angular-devkit/schematics        0.7.0-rc.0
@angular/cdk                      5.2.5
@angular/cli                      1.7.0
@ngtools/webpack                  1.10.0
@schematics/angular               0.7.0-rc.0
@schematics/package-update        0.7.0-rc.0
@schematics/update                0.7.0-rc.0
rxjs                              5.5.11
typescript                        2.5.3
webpack                           4.9.2

admosity avatar Jun 22 '18 22:06 admosity

Also having the not found issue using while using a git+https dependency running @angular/cli 6.0.8

Seems like a common bug, any timeline on the resolution of this?

DavidDecraene avatar Jun 26 '18 08:06 DavidDecraene

Any chance the cli could just log not found errors as a warning instead of exiting on them?

epelc avatar Jun 26 '18 16:06 epelc

Hi Guys,

The issue related with npm's get config command itself.

npm get <key> returns all other configs except _auth and _authToken. Even, npm config list doesn't return them as well.

On update script, it tries to run this command, and this command fails, then actual value became null, so your private registry authentication fails.

https://github.com/angular/angular-cli/blob/6449a753641340d8fc19a752e1a1ced75f974efa/packages/schematics/update/update/npm.ts#L47

So quick and dirty solution is set your auth token manually on ./node_modules/@schematics/update/update/npmjs line number somewhere after 103.

auth = { token: "<your_auth_token", alwaysAuth: true }

FYI: My .npmrc file

strict-ssl=false
registry=https://<company_nexus_npm_registry>
_auth="<base64_token>"
always_auth=true
email=<company_email>

I'll try to create PR for this if anyone created anything similar.

Cheers

tengis avatar Jun 30 '18 09:06 tengis

@tengis that's some great debugging friend! I just tried this out, and it works beautifully ;)

Important notice for people trying out this fix too, you need to have at least version 6.1.0-rc0 of the @angular/cli package, before editing the npm.js file as suggested.

What PR do you suggest to create, one that fixes the issue in npm itself, or one that 'patches' it in CLI by fetching it somehow from .npmrc and adding it in manually?

Timebutt avatar Jun 30 '18 11:06 Timebutt

Thinking about it, you probably won't be able to change this in npm itself as _auth and _authToken are secrets, and it is desired behaviour to never hand them out using npm get {KEY}, judging from following terminal output:

npm get _authToken                                                                                                                                                         
npm ERR! ---sekretz---

Timebutt avatar Jun 30 '18 11:06 Timebutt

@Timebutt Or perhaps add --auth flag on ng update command?!

tengis avatar Jul 01 '18 00:07 tengis

I really wonder why not using plain npm and make use of the build in authentication. Adding an --auth flag so I have to add authentication again for angular. Very bad idea. Parse .npmrc or just use npm.

DaSchTour avatar Jul 02 '18 06:07 DaSchTour

We have the same issue now. Does anyone have a solution for this problem?

jusefb avatar Jul 04 '18 15:07 jusefb

still seeing this behavior in @angular/[email protected]

beanian avatar Jul 18 '18 13:07 beanian

even in official 6.1 it's still an issue

modul8com avatar Jul 26 '18 08:07 modul8com

Well I don't think that this will be solved any time soon, just guessing by how it is labled.

DaSchTour avatar Jul 26 '18 11:07 DaSchTour

The good news: I found a bug report that precisely describes the issue we're experiencing The bad news: It's been open since May

😭

roblarsen avatar Jul 26 '18 16:07 roblarsen

Our workaround was to remove our private package, then run...

ng update --registry=https://registry.npmjs.org/ @angular/cli

and then re-install the private package.

The worst? Or simply the worst? The worst.

roblarsen avatar Jul 26 '18 18:07 roblarsen

my hack/solution:

go to node_modules\@schematics\update\update\npm.js and change line 35-ish (first line of the method)

function getNpmClientSslOptions(strictSsl, cafile) {
    const sslOptions = { strict: false }; // <---- RIGHT HERE.. normally, it's "{}"
    if (strictSsl === 'false') {
        sslOptions.strict = false;
    }
    else if (strictSsl === 'true') {
        sslOptions.strict = true;
    }
    if (cafile) {
        sslOptions.ca = fs_1.readFileSync(cafile);
    }
    return sslOptions;
}

Not sure why it's not getting the setting from the .npmrc file, but this let me get past the issue

tommck avatar Jul 27 '18 13:07 tommck