By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng add and update ignore npm global config

🔬 Minimal Reproduction

Define a private registry (it's also an proxy for publics packages)

npm config set registry https://myregistry/repository/myrepo/ --global

Set authentication

npm login --registry=https://myregistry/repository/myrepo/ 

Install angular/cli

npm install -g @angular/cli

And start a new project

ng new myproj

Ok project created and all dependencies installed (private registry checked in package-lock.json)

The problem starts here
I want to transform my project to pwa see

ng add @angular/pwa --project myproj

response : The add command requires to be run in an Angular project, but a project definition could not be found.
Ok change directory

cd myproj
ng add @angular/pwa

response : Unable to fetch package metadata: request to https://registry.npmjs.org/@angular%2fpwa failed, reason: connect ETIMEDOUT 104.16.26.35:443. (I'am also behind a enterprise proxy)

same result with update command, ng command want to access directly to registry.npmjs.org and not by private registry

🌍 Your Environment

Angular CLI: 8.1.0 Node: 10.10.0 OS: win32 x64 Angular: 8.1.0 ... animations, cli, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Package Version ----------------------------------------------------------- @angular-devkit/architect 0.801.0 @angular-devkit/build-angular 0.801.0 @angular-devkit/build-optimizer 0.801.0 @angular-devkit/build-webpack 0.801.0 @angular-devkit/core 8.1.0 @angular-devkit/schematics 8.1.0 @ngtools/webpack 8.1.0 @schematics/angular 8.1.0 @schematics/update 0.801.0 rxjs 6.4.0 typescript 3.4.5 webpack 4.35.2

Npm version -> 6.9.2

Hi, I tried this out and global npmrc is being read.

ng add baz
Unable to fetch package metadata: request to https://myregistry/repository/myrepo/baz failed, reason: getaddrinfo ENOTFOUND myregistry **myregistry:443**

Can you kindly check where your global npmrc is being saved?

We need a real repository @alan-agius4 . myregistryis an example.
For resolve this issue i added registry
ng add @angular/pwa --registry=https://myregistry/repository/myrepo/ and it's work

In user directory, the file .npmrc contains credentials for registry, but not registry address.
The registry address is stored in %APPDATA%\roaming\npm\etc\npmrc
Location documentation

with ng update --registry=.... doesn't work

At the moment there is no way to turn on the verbose logging for `ng update` and `ng add`. This is useful for use so that when users report issues such as npmrc is not read we can see the lookup locations.
This also removes some reduncant that were being provided in `executeSchematic`.
Related to #14993
At the moment there is no way to turn on the verbose logging for `ng update` and `ng add`. This is useful for use so that when users report issues such as npmrc is not read we can see the lookup locations.
This also removes some reduncant that were being provided in `executeSchematic`.
Related to #14993

We have the same problem with @angular/cli 9.1.0.
The command ng update @angular/core produces

An unhandled exception occurred: request to https://registry.npmjs.org/@angular%2fcli failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org

even though our global npmrc specifies our company npm-registry - Output of npm config list is

; builtin config undefined
cache = "C:\Users\t196\AppData\Local\npm-cache"
prefix = "C:\Users\t196\AppData\Local\npm-global"
registry = "https://nexus.mycompany.com/repository/npm-all/"

; node bin location = C:\Program Files\nodejs\12.13.1\node.exe
; cwd = C:\Workspaces\my-app\ui

We have the inverse issue. Our local .npmrc is ignored but if we copy the local file as user config it works.
The config contains the local registry and root certificate of our company:

$ ls .npmrc
.npmrc
$ ng update --verbose
Locating potential npmrc files:
Trying 'C:\Program Files\nodejs\etc\npmrc'...not found.
Trying 'D:\Users\user\.npmrc'...not found.
Trying 'D:\Users\.npmrc'...not found.
Trying 'D:\Users\user\.npmrc'...not found.
Trying 'D:\Users\user\projects\.npmrc'...not found.
Trying 'D:\Users\user\projects\angular\.npmrc'...found.
The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
An unhandled exception occurred: npm ERR! code SELF_SIGNED_CERT_IN_CHAIN
npm ERR! errno SELF_SIGNED_CERT_IN_CHAIN
npm ERR! request to https://registry.npmjs.org/@angular%2fcli failed, reason: self signed certificate in certificate chain
[SNIP]
$ cp .npmrc ~/.npmrc
$ ng update --verbose
Locating potential npmrc files:
Trying 'C:\Program Files\nodejs\etc\npmrc'...not found.
Trying 'D:\Users\user\.npmrc'...found.
Trying 'D:\Users\.npmrc'...not found.
Trying 'D:\Users\user\.npmrc'...found.
Trying 'D:\Users\user\projects\.npmrc'...not found.
Trying 'D:\Users\user\projects\angular\.npmrc'...found.
The installed local Angular CLI version is older than the latest stable version.
Installing a temporary version to perform the update.
Installing packages for tooling via npm.
Installed packages for tooling via npm.
Using package manager: 'npm'
Collecting installed dependencies...
Found 57 dependencies.
[SNIP]
          

Not sure if this is a diff issue, but we have our npm config entries set up in memory rather than in our npmrc files, and the correct values are used when we do a npm config list, however ng update seems to completely ignore those and instead use the ones in npmrc (which is the default, empty npmrc, doesn't have the correct values). This issue has been open a long time, is there going to be any fix for this?

I think I'm having a similar problem while updating from angular 11 to angular 12 :
npm config get registry returns the path to our artifactory registry
However, when I try ng update @angular/cli I get this:
npm ERR! code E403
npm ERR! 403 403 DefaultErrorTemplate - GET https://registry.npmjs.org/@angular%2fcli
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.
Which is expected since the global registry access is blocked by the company proxy.
The command is not supposed to poke anything but the provided registry.

May I add that trying by hand calling https://mycompanyregistry/@angular%2fcli does work.

Thanks for reporting this issue. Luckily, it has already been fixed in one of the recent releases. Please update to the most recent version to resolve the problem.

If the problem persists in your application after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior. You can use ng new repro-app to create a new project where you reproduce the problem.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.