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

+1, can't we just read the .npmrc on install or have an alternative flag that skips the npm check and simply updates angular?

evanjmg avatar Oct 21 '18 12:10 evanjmg

@lonaru

Angular cli STILL does not work with Font-Awesome pro npm authentication As for @lonaru the @smnbbrv fix does not work and error 401 Unauthorized is thrown wen updating Cli to version 7 I have no .npmrc locally, only a global one.

I spent a lot of time updating to 6.1 because of FontAwsome authentication and using Font-Awesome is again a problem. Can this be dealt with once and for all ?

PMoransais avatar Oct 22 '18 15:10 PMoransais

Hi @Ionaru @evanjmg @PMoransais

could you try to add to your .npmrc the following line?

always-auth=true

or / and

//npm.fontawesome.com/:always-auth=true

Does this help?

smnbbrv avatar Oct 23 '18 16:10 smnbbrv

Works for me ! Thanks @smnbbrv !

mvsrinivasan avatar Oct 23 '18 17:10 mvsrinivasan

Super! If this works for the rest of the guys, I guess the issue is pretty much solved.

Could someone of fontawesome users post a request on their repo (or whatever contact they provide) to include this setting into documentation? This is a (very) common configuration item for the private repos and, well, then I don't understand why it's not there yet.

smnbbrv avatar Oct 23 '18 18:10 smnbbrv

It might work for font-awesome (i wouldn't know i dont use it), but it still doesn't work for a npm proxy that has authentication. E.g when you have a nexus server keeping a "local" (to the office network cache) of the default npm repository - there where all the public stuff like angular gets downloaded from by default (explained in my previous https://github.com/angular/angular-cli/issues/10624#issuecomment-421544428)

Steps to reproduce:

  1. Login to your private npm proxy `npm login --registry=https://nexus.myorg.com/repository/npm"
  2. Now try to upgrade your existing project ng upgrade 2.1) Even try `ng upgrade --registry=https://nexus.myorg.com/repository/npm"

After waiting quite a while it errors with "This request requires auth credentials. Run npm login and repeat the request." Looking at my nexus logs I can see it never even attempted to download from the registry.

Because ng update doesn't have a --verbose options, I can't really tell where it is trying to download from....

trojanc avatar Oct 23 '18 19:10 trojanc

@trojanc please post your .npmrc

smnbbrv avatar Oct 24 '18 05:10 smnbbrv

@trojanc please post your .npmrc

//nexus.mydomain.co.za/repository/npm/:_authToken=NpmToken.xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
registry=https://nexus.mydomain.co.za/repository/npm
always-auth=true

trojanc avatar Oct 24 '18 17:10 trojanc

I think I found it...very much hidden I'd say. For me the issue was the LOCATION of the .npmrc file. Angular does not search for the file in the default location on windows. Normally the file is in C:\Users\username\.npmrc instead Angular searches for the file in C:\Users\username\AppData\Local\.npmrc. Copying the file to there solved my issue. Now just to remember that every change I make to the normal location of npmrc - like when using npm cli to add repos - to copy that file to where Angular is looking for it

trojanc avatar Oct 24 '18 18:10 trojanc

@smnbbrv ng update still doesn't work for me. the .npmrc is in the same directory as the angular.json and contains always-auth=true and an artifactory url for registry. there is also the ~/.npmrc which contains the _authToken. i'm using yarn as packageManager but however also removed the packageManager config from angular.json to use npm. installation and updating of dependencies via npm and yarn works fine (so auth data should be correct). it takes some time and outputs then This request requires auth credentials. Run npm login and repeat the request.. Angular CLI version 7.0.2, yarn version v1.10.1. any suggestions?

cstickel avatar Oct 24 '18 20:10 cstickel

@mixer2 this is not yet implemented case. Try to put _authToken into the registry's .npmrc or use only global .npmrc, should work for one or another but not both

smnbbrv avatar Oct 24 '18 21:10 smnbbrv

@smnbbrv thx for the quick reply. i tried to add the auth data to the .npmrc of the project and also to remove that one and add always-auth and registry to the ~/.npmrc. unfortunately, both combinations didn't work -.- any other ideas?

cstickel avatar Oct 24 '18 21:10 cstickel

pretty much same experience here while running ng update:

Your global Angular CLI version (7.0.3) is greater than your local
version (6.1.1). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Unexpected token  in JSON at position 0
{"$id":"1","innerException":null,"message":"TF400813: Resource not available for anonymous access. Client authentication required.","typeName":"Microsoft.TeamFoundation.Framework.Server.UnauthorizedRequestException, Microsoft.TeamFoundation.Framework.Server","typeKey":"UnauthorizedRequestException","errorCode":0,"eventId":3000}

always-auth=true does not fix it copying private .npmrc to C:\Users\username\AppData\Local\.npmrc does not work either

GeorgeKnap avatar Oct 26 '18 07:10 GeorgeKnap

Please double check your .npmrc especially when you use scoped repositories with scoped authTokens. E.g. I had the following in my .npmrc @myscope:registry=https://private.artifactory.instance/api/npm/private-npm/ //private.artifactory.instance/api/npm/private-npm/:_authToken=myAuthToken The problem is that https://github.com/angular/angular-cli/blob/master/packages/schematics/update/update/npm.ts#L73 is searching for the exact match of the scraped string "//private.artifactory.instance/" which doesn't match (path variables are removed).

To the Angular devs: This could be solved by adding a fuzzy matching into the getOptionFromNpmRc function but could then lead to other side effects. Nevertheless this should be covered in a better way (by adding more examples) to the documentation.

ThYpHo0n avatar Oct 26 '18 12:10 ThYpHo0n

I'm having this issue with ng-uikit-pro-standard.

xinthose avatar Oct 26 '18 13:10 xinthose

@ThYpHo0n thanks! that was exactly the issue i had... it's a bit unfortunate that they share the .npmrc config with npm/yarn but interpret it different in multiple ways. especially the run npm login hint in the error is misleading, because it will create the _authToken in antoher file and with another registry scope than ng update would expect. so for now the imho most reliable way to go is to manually add the _authToken with manually modified scope to the projects .npmrc, do the updates and then remove the token again to not accidentally push it.

cstickel avatar Oct 26 '18 16:10 cstickel

The team is aware of the issue and there is a pending PR (https://github.com/angular/angular-cli/pull/12526) which will vastly improve the current situation. Unfortunately, it is currently blocked on an upstream issue (https://github.com/zkat/pacote/issues/163).

clydin avatar Oct 26 '18 17:10 clydin

I tried 7.1.0-beta.0 and don't get "unauthenticated" anymore but it still fails.

Am I too soon? :) I just saw there were changes in the latest release If not: Go on reading

ng update @angular/core now throws a 404 with

404 Not Found - GET https://registry.npmjs.org/@myScope%2fmyPackage - Not found

The thing is, this is a package stored in our private npm registry and should not be fetched from npmjs.org

I tried to

ng update @angular/core --registry https://registry.my-private-registry.com/repository/next.npm.group

But it fails with Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"

I tried to remove my scope declaration for our registry in my .npmrc

@myScope:registry=__REGISTRY_URL__

didn't work

Tried always-auth=true => Didn't work

kroeder avatar Nov 02 '18 16:11 kroeder

Same here! All solutions didn't work for me

rafa-suagu avatar Nov 06 '18 10:11 rafa-suagu

My workaround was to only migrate (which worked) and then upgrade the packages manually.

ng update @angular/cli --migrateOnly (maybe you need to move the entries inside the home/.npmrc or .yarnrc into the project's corresponding file)

After that went ok, I i,e, used yarn update @angular/[email protected] (working with yarn here)

Unfortunately I can't really find what else ng update does and hope that these two steps are sufficient.

daniel-seitz avatar Nov 09 '18 15:11 daniel-seitz