有没有办法让 npm install (命令)在代理后面工作? [英] Is there a way to make npm install (the command) to work behind proxy?
问题描述
在 .npmrc
文件中阅读有关代理变量的信息,但它不起作用.尽量避免手动下载所有需要的包并安装.
Read about a proxy variable in a .npmrc
file but it does not work. Trying to avoid manually downloading all require packages and installing.
推荐答案
我是这样解决这个问题的:
I solved this problem this way:
我运行这个命令:
I run this command:
npm config set strict-ssl false
然后将 npm 设置为使用 http 而不是 https 运行:
Then set npm to run with http, instead of https:
npm config set registry "http://registry.npmjs.org/"
然后我使用以下语法安装软件包:
Then I install packages using this syntax:
npm --proxy http://username:password@cacheaddress.com.br:80 install packagename
如果代理不需要您进行身份验证,请跳过 username:password
部分
我的一个朋友刚刚指出,您可以通过设置 BOTH HTTP_PROXY 和 HTTPS_PROXY 环境变量,然后正常发出命令来让 NPM 在代理后面工作npm install express(例如)
A friend of mine just pointed out that you may get NPM to work behind a proxy by setting BOTH HTTP_PROXY and HTTPS_PROXY environment variables, then issuing normally the command npm install express (for example)
正如@BStruthers 所评论的,请记住,包含@"的密码将不会被正确解析,如果包含 @ 将整个密码放在引号中
As @BStruthers commented, keep in mind that passwords containing "@" wont be parsed correctly, if contains @ put the entire password in quotes
这篇关于有没有办法让 npm install (命令)在代理后面工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!