[英]How to setup Node.js and Npm behind a corporate web proxy
How can I configure node.js
and npm
to run behind a web proxy? 如何配置
node.js
和npm
在Web代理后面运行?
I tried the following solutions but they didn't work for me. 我尝试了以下解决方案,但它们对我不起作用。
npm config set proxy http://proxy.company.com:8080
and 和
npm config set proxy http://username:password@proxy.company.com:8080
First open a command console at the location of your npm
installation. 首先在
npm
安装位置打开命令控制台。
Then you can configure your npm to use a proxy using the commands: 然后,您可以使用以下命令将npm配置为使用代理:
npm config set proxy http://{url}:{port}
npm config set https-proxy http://{url}:{port}
Notice the protocol is set to http
for both the proxy
and https-proxy
variables. 注意协议设置为
http
两者的proxy
和https-proxy
变量。
If you would like npm
to store your credentials for the proxy, you can additionally modify the commands as follows: 如果您希望
npm
存储代理的凭据,则可以如下另外修改命令:
npm config set proxy http://{username}:{passphrase}@{url}:{port}
npm config set https-proxy http://{username}:{passphrase}@{url}:{port}
For example: 例如:
npm config set proxy http://LanguidSquid:Password1@my.company.com:8080
npm config set https-proxy http://LanguidSquid:Password1@my.company.com:8080
Additional information here: Using npm behind corporate proxy .pac 此处的其他信息: 在公司代理.pac之后使用npm
This worked for me! 这对我有用!
NOTE: Remember to add https:// instead of http:// when setting registry 注意:请记住在设置注册表时添加https://而不是http://
Hope that helps. 希望能有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.