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

前端 未结 29 1006
隐瞒了意图╮
隐瞒了意图╮ 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: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.

提交回复
热议问题