node.js 407认证需要npm
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49902035/
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
407 Authentication required npm
提问by AndiFB
Hello everyone I′ve been trying to configure and use npm on my enterprise PC without success.
大家好,我一直在尝试在我的企业 PC 上配置和使用 npm,但没有成功。
I′ve set proxy, https-proxy, strict-ssl false, registry http://registry.npmjs.orgproxy has been set like this "http://user:password@proxy_ip:proxy:port" Where the password has a special character written in urlencode.
我已经设置了代理,https-proxy,strict-ssl false,registry http://registry.npmjs.org代理已经设置成这样“ http://user:password@proxy_ip:proxy:port” 其中密码有用 urlencode 编写的特殊字符。
npm config get proxy
returns proxy with credentials as they should be.
返回具有应有凭据的代理。
I have cleared my npm cache and tried again.
我已经清除了我的 npm 缓存并再次尝试。
No success.
没有成功。
Any ideas what can be the problem?
任何想法可能是什么问题?
回答by lautit
Usually, when you are behind a corporate proxy, it is needed to add the domain where you are at. Given that also the characters should be URL encoded, it would look like:
通常,当您使用公司代理时,需要添加您所在的域。鉴于字符也应该是 URL 编码的,它看起来像:
回答by Suhas Gavad
I recommend reading through this article to configure the proxy for npm. http://wil.boayue.com/blog/2013/06/14/using-npm-behind-a-proxy/
我建议通读这篇文章来为 npm 配置代理。 http://wil.boayue.com/blog/2013/06/14/using-npm-behind-a-proxy/
npm config set proxy http://proxy.company.com:proxyportnpm config set http-proxy http://proxy.company.com:proxyportnpm config set https-proxy http://proxy.company.com:proxyport
npm config set proxy http://proxy.company.com:proxyportnpm config set http-proxy http://proxy.company.com:proxyportnpm config set https-proxy http://proxy.company.com:proxyport
Hope this is useful for you!
希望这对你有用!
回答by Deepa
We should add proxy with username and password to avoid this error. For example:
我们应该添加带有用户名和密码的代理以避免此错误。例如:
- username: admin
- password: admin123
- proxy: 172.10.3.21
- port: 3128
- 用户名:admin
- 密码:admin123
- 代理:172.10.3.21
- 端口:3128
npm config set proxy http://admin:[email protected]:3128
npm config set https-proxy http://admin:[email protected]:3128
回答by Vishnu C Mohan
Editing the .npmrc file in user folder worked for me. I set the proxy and npm registry as follows:
编辑用户文件夹中的 .npmrc 文件对我有用。我将代理和 npm 注册表设置如下:
proxy=http://username:password@proxy:port/
https-proxy=http://username:password@proxy:port
registry=http://registry.npmjs.org/
Note : for usenames and passwords containing special charcters, the characters need to be encoded in the proxy configuration. e.g if username is "user" and password is "1234@user", then the .npmrc file will look like :
注意:对于包含特殊字符的用户名和密码,需要在代理配置中对字符进行编码。例如,如果用户名是“user”,密码是“1234@user”,那么 .npmrc 文件将如下所示:
proxy=http://user:1234%40user@proxy:port/
https-proxy=http://user:1234@user@proxy:port
registry=http://registry.npmjs.org/
where, %40 is the encoded form of "@". In my case, the pound symbol(#) was not getting accepted in username or password(Dont know why).
其中,%40 是“@”的编码形式。就我而言,用户名或密码中没有接受英镑符号(#)(不知道为什么)。

