获取 Node.js npm 命令以在公司代理后面工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19824517/
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
Get Node.js npm command to work behind corporate proxy
提问by jax
I am trying to install bower
我正在尝试安装凉亭
npm install -g bower
npm install -g bower
but am getting an authentication error from our proxy
但我从我们的代理收到身份验证错误
... npm http 407 http://registry.npmjs.org/bower... Error Code: 407 Proxy Authentication Required. ...
... npm http 407 http://registry.npmjs.org/bower... 错误代码:需要 407 代理身份验证。...
I am trying to get npm working behind a corprate proxy. I think our proxy is a little weird because the only way I was able to get maven downloading packages was to add wagon-http-lightweight.jar as a maven extension.
我试图让 npm 在公司代理后面工作。我认为我们的代理有点奇怪,因为我能够获得 maven 下载包的唯一方法是添加 wagon-http-lightweight.jar 作为 maven 扩展。
http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/
http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/
I have tried all the regular things as described here: Is there a way to make npm install (the command) to work behind proxy?
我已经尝试了这里描述的所有常规操作: Is there a way to make npm install (the command) to work behind proxy?
(I don't need to supply authentication details in my maven proxy settings).
(我不需要在我的 Maven 代理设置中提供身份验证详细信息)。
npm config set registry http://registry.npmjs.org/npm config set proxy http://myusername:[email protected]:8080npm config set https-proxy http://myusername:[email protected]:8080npm config set strict-ssl false
npm 配置集注册表http://registry.npmjs.org/npm 配置集代理http://myusername:[email protected]:8080npm 配置集 https-proxy http://myusername:[email protected] .somecompany:8080npm config set strict-ssl false
What else can I try?
我还能尝试什么?
采纳答案by jax
I was able to get this working by installing a local proxy:
我能够通过安装本地代理来实现这一点:
回答by hbthanki
Can try this....working for me.
可以试试这个....对我来说有效。
- Open IE (Chrome did not work for me).
- Hit the URL
http://registry.npmjs.org - it will download json output if successful.
- 打开 IE(Chrome 对我不起作用)。
- 点击网址
http://registry.npmjs.org - 如果成功,它将下载 json 输出。
Now go back to command prompt and try npm install.
现在返回命令提示符并尝试 npm install。
回答by EmptyCup
Use fiddler http://www.telerik.com/fiddlerInstall and run and that's it, everything will run as it is supposed to. I spent half a day cracking my head on this Edit: I honestly have no idea if it was fiddler or something else I tried that fixed it (it is mostly the latter) but you should try setting registry, http-proxy, proxy and strict-ssl
使用 fiddler http://www.telerik.com/fiddler安装并运行,就是这样,一切都会按预期运行。我花了半天时间在这个编辑上破解我的头:老实说,我不知道它是小提琴手还是我尝试过的其他修复它的东西(主要是后者)但你应该尝试设置注册表,http-proxy,代理和严格-ssl
When authentication is required for the HTTP proxy:
当 HTTP 代理需要身份验证时:
Fiddler can be configured to authenticate with the corporate HTTP proxy using NTLM or other protocols. Leave the existing auto authenticate options/rules defaults in place. Instead, go to this setting from the menu bar:
Fiddler 可以配置为使用 NTLM 或其他协议向企业 HTTP 代理进行身份验证。保留现有的自动身份验证选项/规则默认值。相反,请从菜单栏中转到此设置:
Tools > Telerik Fiddler Options > Connections tab
工具 > Telerik Fiddler 选项 > 连接选项卡
Click on the Allow remote computers to connectcheckbox. You will see a dialog explaining the consequences of enabling this option. Restart Fiddler and update the .npmrcfile as shown above. Whenever you need npm to access the registry site just run Fiddler. This setting won't affect the way Fiddler runs for other captures.
单击允许远程计算机连接复选框。您将看到一个对话框,说明启用此选项的后果。重新启动 Fiddler 并更新.npmrc文件,如上所示。每当您需要 npm 访问注册表站点时,只需运行 Fiddler。此设置不会影响 Fiddler 为其他捕获运行的方式。
回答by Do Tat Hoan
I have the same issue. The root cause is my password contains a special character '#', when I npm set config proxy, the character become '#' in .npmrc file, so I change my password to remove the special character and it's working fine. If your password does not contains special characters, just use syntax command below, it will work.
我有同样的问题。根本原因是我的密码包含一个特殊字符“#”,当我 npm set config proxy 时,该字符在 .npmrc 文件中变成了“#”,所以我更改了密码以删除特殊字符并且它工作正常。如果您的密码不包含特殊字符,只需使用下面的语法命令即可。
npm config set strict-ssl=false
npm config set proxy http://<username>:<password>@<proxy-server-url>:<port>
npm config set https-proxy http://<username>:<password>@<proxy-server-url>:<port>
Thanks,
谢谢,

