Skip to content

ng ignore global npm config for add and update command #14993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

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

Closed
diyfr opened this issue Jul 4, 2019 · 10 comments
Closed

ng ignore global npm config for add and update command #14993

diyfr opened this issue Jul 4, 2019 · 10 comments
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely type: bug/fix workaround1: obvious
Milestone

Comments

@diyfr
Copy link

diyfr commented Jul 4, 2019

Ng command

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [X] add
- [X] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

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

@alan-agius4
Copy link
Collaborator

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?

@diyfr
Copy link
Author

diyfr commented Jul 8, 2019

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

kyliau pushed a commit that referenced this issue Jul 9, 2019
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
kyliau pushed a commit that referenced this issue Jul 9, 2019
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
@alan-agius4 alan-agius4 removed the needs: more info Reporter must clarify the issue label Jul 19, 2019
@StefanMuellerCH
Copy link

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

@StefanMuellerCH
Copy link

StefanMuellerCH commented Apr 8, 2020

Btw, if the global npmrc is copied to the app working directory (.npmrc) the ng update command works correcly using our company registry, so a local config seems to be honored (but a global one should be too).

@SebastianKuehn
Copy link

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]

@d4nc3r
Copy link

d4nc3r commented Feb 10, 2021

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?

@ericparton
Copy link

We're having the same problem with yarn. The local .yarnrc.yml file is completely ignored

@denpokoder
Copy link

denpokoder commented Dec 16, 2021

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.

@alan-agius4
Copy link
Collaborator

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.

@alan-agius4 alan-agius4 added the 2022Q3 Fixit Candidates for the Q3 2022 fix-it label Jun 29, 2022
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
2022Q3 Fixit Candidates for the Q3 2022 fix-it area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely type: bug/fix workaround1: obvious
Projects
None yet
Development

No branches or pull requests

8 participants