node.js NPM 安装导致 401 Unauthorized for private repo
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48823562/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NPM install resulting in 401 Unauthorized for private repo
提问by Karl Morrison
I have the following line in my dependencies in package.json:
我的依赖项中有以下行package.json:
"log": "https://git.mydomain.com/myproject/myrepo/repository/archive.tar.gz?ref=0.1.0",
I get the following:
我得到以下信息:
km@Karls-MBP ~/dev/vertica (km/ref) $ npm install
npm ERR! code E401
npm ERR! 404 401 Unauthorized: log@https://git.mydomain.com/myproject/myrepo/repository/archive.tar.gz?ref=0.5.0
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/km/.npm/_logs/2018-02-16T08_49_38_669Y-debug.log
I don't know if the issue is GitLab (where the repo exists) or NPM.
我不知道问题是 GitLab(存在 repo 的地方)还是 NPM。
- Node v8.9.4
- NPM v5.6.0
- 节点 v8.9.4
- NPM v5.6.0
回答by Abdullah Faruk
Remove .npmrc from the Home Directory, it should be able to work. I did the same and it works for me.
从主目录中删除 .npmrc,它应该可以工作。我做了同样的事情,它对我有用。
回答by santon
My user directory .npmrc file had a stale authtoken as below.
我的用户目录 .npmrc 文件有一个陈旧的身份验证令牌,如下所示。
//registry.npmjs.org/:_authToken=3615fa68-123a-4d72-b99a-772b5b1edc48
//registry.npmjs.org/:_authToken=3615fa68-123a-4d72-b99a-772b5b1edc48
By removing this line, the npm installation works fine and no longer throws an authentication error.
通过删除这一行,npm 安装工作正常并且不再抛出身份验证错误。
回答by Salah Atwa
You need to add user to npm registery
您需要将用户添加到 npm registery
>> npm whoami [ it will return not authorized ]
To add new user follow below steps :-
要添加新用户,请按照以下步骤操作:-
>> npm adduser (then enter your name and complex password and your email)
>> npm whoami (return your registered name)
回答by Vivek Kodira
I noticed this error for a public github repo. Removed the entry always-auth = trueand was able to proceed.
我注意到公共 github 存储库的此错误。删除了条目always-auth = true并能够继续。

