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

It works now using rc.0 and

ng update @angular/core --registry https://%registry/repository/%group-name%/

Not a solution but a workaround 😃

kroeder avatar Nov 23 '18 09:11 kroeder

@kroeder does your .npmrc literally have the %'s or are those only for comment replacement purposes?

clydin avatar Nov 26 '18 18:11 clydin

Just placeholders because I don't want to share the exact URL :) have no vars

kroeder avatar Nov 26 '18 19:11 kroeder

Hmm.

I have globally and locally @angular/cli 7.1.0. Our project uses '@angular/*' "^6.1.0".

Did a clean yarn install - there was no yarn.lock or node_modules prior to the install.

Then I wanted to perform ng update '@angular/cli'.

I got this red line as result:

401 Unauthorized - GET https://npm.fontawesome.com/@fortawesome%2fpro-regular-svg-icons

Same result with ng update '@angular/core'.

As a reminder, our local .npmrc is (we do not use .npmrc in HOME directory):

@XXXXXXXXXX:registry=https://artifactory.YYYYYYYYYY:443/artifactory/api/npm/npm-virtual/

@fortawesome:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=${NPM_TOKEN_FONTAWESOME}

PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true

depth=0
loglevel=warn
package-lock=false
progress=false

It only works if I replace ${NPM_TOKEN_FONTAWESOME} with the real token string.

I take it @clydin's enhancement to support ENV variables in .npmrc has not landed yet.

catull avatar Nov 26 '18 20:11 catull

@catull The environment variable support will be in 7.1.1.

clydin avatar Nov 26 '18 20:11 clydin

Excellent, thanks!

catull avatar Nov 26 '18 20:11 catull

+1 same issue with 7.1.0 - @microsoft fix it

manish-jain-1 avatar Nov 28 '18 07:11 manish-jain-1

The problem for angular-cli 7.1.0 is in angular-cli/packages/schematics/update/update/npm.ts

const resultPromise = pacote.packument(
    packageName,
    {
      'full-metadata': true,
      ...npmrc,
      registry: options && options.registryUrl,
    },
  );

This line contains error: registry: options && options.registryUrl

If you pass any cli options, but don't pass registryUrl inside this options - this line will generate "registry: undefined" that always overrides ".npmrc" value.

And pacote when see this - uses default registry.npmjs.org

The fix is simple - check that options.registryUrl has some value, before passing it to pacote. I can try to make a fix, and also some tests for it :)

denisoby avatar Nov 30 '18 18:11 denisoby

@denisoby Don't bother.

@hansl committed a fix with https://github.com/angular/angular-cli/commit/6fce79355fb6305f3db2e627fdf345b9ac1f173b @clydin enhanced it with https://github.com/angular/angular-cli/pull/13106/commits/e85da635cd70ddcf1eddee430a7d740eaa3bc53e

Just wait for version @angular/[email protected]

Edit: It has landed now. Enjoy it!

catull avatar Dec 01 '18 09:12 catull

With 7.1.1 I get 404 errors again. Scoped packages seams not to be recognized correctly.

DaSchTour avatar Dec 04 '18 15:12 DaSchTour

Is there an article describing what to do know? Im using Windows and don't know how to get it working:

  • Use .npmrc in local and/or HOME ?
  • Do I have to use environment variables for auth-keys?

Deleted my local .nmprc to update version of @angular/cli to 7.1.1. Restored the local .npmrc and trying to start ng update

If I then try to start ng update getting also the 404 with scoped package names: like: /@angular-devkit%2fbuild-angular

cluen avatar Dec 05 '18 13:12 cluen

This should have been fixed by https://github.com/angular/angular-cli/pull/13025

alan-agius4 avatar Dec 07 '18 12:12 alan-agius4

@alan-agius4 I am running 7.1.2 and I still have this problem with a private repo.

jonasmohrcodes avatar Dec 07 '18 12:12 jonasmohrcodes

@Albyzai can you kindly try to use the next version? Note that you should also update @angular/devkit packages

alan-agius4 avatar Dec 07 '18 12:12 alan-agius4

@alan-agius4

This is my output:

    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.1.2
Node: 8.12.0
OS: win32 x64
Angular: 7.1.2
... animations, cli, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.10.7
@angular-devkit/build-angular     0.10.7
@angular-devkit/build-optimizer   0.10.7
@angular-devkit/build-webpack     0.10.7
@angular-devkit/core              7.0.7
@angular-devkit/schematics        7.1.2
@angular/cdk                      7.1.1
@ngtools/webpack                  7.0.7
@schematics/angular               7.1.2
@schematics/update                0.11.2
rxjs                              6.3.3
typescript                        3.1.1
webpack                           4.19.1

jonasmohrcodes avatar Dec 07 '18 12:12 jonasmohrcodes

@Albyzai, can you try to use @angular/cli@next and see if the problem persists?

alan-agius4 avatar Dec 07 '18 13:12 alan-agius4

@alan-agius4

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.2.0-beta.1
Node: 8.12.0
OS: win32 x64
Angular: 7.1.2
... animations, common, compiler, compiler-cli, core, forms
... http, platform-browser, platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.10.7
@angular-devkit/build-angular     0.10.7
@angular-devkit/build-optimizer   0.10.7
@angular-devkit/build-webpack     0.10.7
@angular-devkit/core              7.0.7
@angular-devkit/schematics        7.2.0-beta.1
@angular/cdk                      7.1.1
@angular/cli                      7.2.0-beta.1
@ngtools/webpack                  7.0.7
@schematics/angular               7.2.0-beta.1
@schematics/update                0.12.0-beta.1
rxjs                              6.3.3
typescript                        3.1.1
webpack                           4.19.1

Problem still persists.

jonasmohrcodes avatar Dec 07 '18 13:12 jonasmohrcodes

btw. is this going to be released into ^6.x.x?

There are quite some repos still out there on versions before 6 and the angular-team behind https://update.angular.io doesn't recommend to move across multiple major versions.

Hence it would be great to get it into 6 as well.

daniel-seitz avatar Dec 07 '18 16:12 daniel-seitz

It works for me, since 7.1.1.

@Albyzai Care to show us your .npmrc, mask out the spicy bits.

catull avatar Dec 07 '18 17:12 catull

@catull

Will do on Monday, got it on my work PC.

jonasmohrcodes avatar Dec 07 '18 19:12 jonasmohrcodes