我需要通过 npm 下载几个包,但我们的公司代理配置是一个 .pac 文件(我在 windows 上)
我已经试过了
npm config set proxy http://mydomain\username:password@1.2.3.4:8181/proxy.pac
npm config set https-proxy http://mydomain\username:password@1.2.3.4:8181/proxy.pac
或
npm config set proxy http://1.2.3.4:8181/proxy.pac
npm config set https-proxy http://1.2.3.4:8181/proxy.pac
但它不起作用......
有什么建议吗?谢谢
最佳答案
我刚刚遇到了一个非常相似的问题,我无法让 npm 在我们的代理服务器后面工作。
我的用户名格式为“域\用户名” - 在代理配置中包含斜杠会导致出现正斜杠。所以输入这个:
npm config set proxy "http://domain\username:password@servername:port/"
然后运行此 npm config get proxy
将返回:
http://domain/username:password@servername:port/
因此,为了解决这个问题,我改为对反斜杠进行 URL 编码,所以输入了这个:
npm config set proxy "http://domain%5Cusername:password@servername:port/"
这样代理访问就被修复了。
关于node.js - 在公司代理 .pac 后面使用 npm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25660936/