Is there a way to make npm install (the command) to work behind proxy?

前端 未结 29 995
隐瞒了意图╮
隐瞒了意图╮ 2020-11-22 08:08

Read about a proxy variable in a .npmrc file but it does not work. Trying to avoid manually downloading all require packages and installing.

相关标签:
29条回答
  • 2020-11-22 08:37

    Use below command at cmd or GIT Bash or other prompt

    $ npm config set proxy "http://192.168.1.101:4128"

    $ npm config set https-proxy "http://192.168.1.101:4128"

    where 192.168.1.101 is proxy ip and 4128 is port. change according to your proxy settings. its works for me.

    0 讨论(0)
  • 2020-11-22 08:38

    Though there are already many good advice, for my environment(Windows 7, using PowerShell) and the last version available of node.js ( v8.1.2 ) all the above did not worked, except when I followed brunowego settings.

    So check your settings with :

    npm config list
    

    Settings behind a proxy:

    npm config set registry http://registry.npmjs.org/
    npm config set http-proxy http://username:password@ip:port
    npm config set https-proxy http://username:password@ip:port
    npm config set proxy http://username:password@ip:port
    npm set strict-ssl false
    

    Hope this will save time to someone

    0 讨论(0)
  • 2020-11-22 08:38
    npm config set proxy <http://...>:<port_number>
    npm config set registry http://registry.npmjs.org/
    

    This solved my problem.

    0 讨论(0)
  • 2020-11-22 08:38

    This worked for me. Set the http and https proxy.

    • npm config set proxy http://proxy.company.com:8080
    • npm config set https-proxy http://proxy.company.com:8080
    0 讨论(0)
  • 2020-11-22 08:38

    My issue came down to a silly mistake on my part. As I had quickly one day dropped my proxies into a windows *.bat file (http_proxy, https_proxy, and ftp_proxy), I forgot to escape the special characters for the url-encoded domain\user (%5C) and password having the question mark '?' (%3F). That is to say, once you have the encoded command, don't forget to escape the '%' in the bat file command.

    I changed

    set http_proxy=http://domain%5Cuser:password%3F@myproxy:8080
    

    to

    set http_proxy=http://domain%%5Cuser:password%%3F@myproxy:8080
    

    Maybe it's an edge case but hopefully it helps someone.

    0 讨论(0)
提交回复
热议问题