Angular ng update @angular/...返回401未经授权 [英] Angular `ng update @angular/...` returns `401 Unauthorized`
问题描述
npm -v
返回6.0.0
node -v
返回v10.0.0
Angular CLI的本地和全局版本为6.0.0
Angular CLI local and global version is 6.0.0
我用ng new sample
创建一个新程序包,运行npm install
没有问题,然后尝试ng update @angular/core
或ng update @angular/cli
并得到401 Unauthorized
作为响应.
I create a new package with ng new sample
, run npm install
without issue, and then I try ng update @angular/core
or ng update @angular/cli
and get 401 Unauthorized
in response.
尝试在已经存在的Angular 6存储库上运行更新似乎是多余的,但是我在Angular 5存储库中也遇到了这个问题.
Trying to run update on an already Angular 6 repository does seem redundant but I also have this issue with an Angular 5 repository.
对于这个错误,我没有什么可做的,是专门针对ng update
还是更可能是其外部的一些无关配置?
I don't have a lot to go on from this error, is it something to do specifically with ng update
or more likely to be some unrelated configuration outside of it?
推荐答案
我一直在处理相同的错误消息.对我来说,这是由项目目录中的自定义.npmrc
引起的,其中包含有关如何连接到我们的npm注册表的信息.
I was struggling with the same error message. For me it was caused by a custom .npmrc
in the project directory which contained information about howto connect to our npm registry.
这是我的解决方法:
- 在更新过程中删除了文件(
mv .npmrc backup.npmrc
) - 从
package.json
的内部npm注册表中删除了对工件的所有依赖关系
- 运行
ng update @angular/cli
- 将文件移回旧位置
mv backup.npmrc .npmrc
- 运行
npm install
(只是为了确定)
- removed the file during the update (
mv .npmrc backup.npmrc
) - removed all dependencies to artifacts from our internal npm registry from the
package.json
- ran
ng update @angular/cli
- moved file back to old position
mv backup.npmrc .npmrc
- ran
npm install
(just to make sure)
我还在 https://github.com/angular创建了angular-cli问题/angular-cli/issues/10704
这篇关于Angular ng update @angular/...返回401未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!