在公司代理 .pac 后面使用 npm [英] Using npm behind corporate proxy .pac
问题描述
我需要通过 npm 下载几个包,但我们公司的代理配置是一个 .pac 文件(我在 Windows 上)
I need to download several packages through npm but our corporate proxy configuration is a .pac file (i'm on windows)
我已经试过了
npm config set proxy http://mydomainusername:password@1.2.3.4:8181/proxy.pac
npm config set https-proxy http://mydomainusername: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 在我们的代理服务器后面工作.
I've just had a very similar problem, where I couldn't get npm to work behind our proxy server.
我的用户名采用域用户名"形式 - 在代理配置中包含斜杠导致出现正斜杠.所以输入这个:
My username is of the form "domainusername" - including the slash in the proxy configuration resulted in a forward slash appearing. So entering this:
npm config set proxy "http://domainusername:password@servername:port/"
然后运行这个 npm config get proxy
返回这个:http://domain/username:password@servername:port/
then running this npm config get proxy
returns this:
http://domain/username:password@servername:port/
因此,为了解决这个问题,我改为对反斜杠进行 URL 编码,因此输入:
Therefore to fix the problem I instead URL encoded the backslash, so entered this:
npm config set proxy "http://domain%5Cusername:password@servername:port/"
这样一来,代理访问就得到了修复.
and with this the proxy access was fixed.
这篇关于在公司代理 .pac 后面使用 npm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!