有没有办法使npm install(命令)在代理后面工作? [英] Is there a way to make npm install (the command) to work behind proxy?

查看:222
本文介绍了有没有办法使npm install(命令)在代理后面工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

了解.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:

  1. 我运行以下命令:

  1. 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屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆