How to clear https proxy setting of NPM?

2019-01-09 22:59发布

How can I clear the previous ssl proxy setting of NPM? well, I search a lot, but all post I got is mainly about how to set proxy in corporate network.

I try to set proxy to nothing:

npm config set http-proxy
npm config set https-proxy

the first command pass yet the second one warn that:

npm WARN invalid config proxy=""
npm WARN invalid config Must be a full url with 'http://'

is the warning neglectable and I have successfully clear the proxy setting?

标签: node.js proxy
26条回答
Lonely孤独者°
2楼-- · 2019-01-09 23:32
npm config delete http-proxy
npm config delete https-proxy

npm config delete proxy -g
npm config delete http-proxy -g

then

npm config get proxy

null

also

npm i -g bower to update

npm had a bug on the proxy

查看更多
狗以群分
3楼-- · 2019-01-09 23:34

None of the above helped me, but this did:

npm config rm proxy
npm config rm https-proxy

Source: http://jonathanblog2000.blogspot.ch/2013/11/set-and-reset-proxy-for-git-and-npm.html

查看更多
疯言疯语
4楼-- · 2019-01-09 23:34

In my case (Linux Mint 16 based on Ubuntu), I had to:

  1. npm config delete https-proxy, and also

  2. clear the https_proxy Bash environment parameter — oddly enough, although I cannot find this behavior documented anywhere, npm fallbacks to https_proxy:

    $ http_proxy='' https_proxy='' npm config get https-proxy
    null
    $ http_proxy='' xxhttps_proxy='' npm config get https-proxy
    https://1.2.3.4:8080
    
查看更多
唯我独甜
5楼-- · 2019-01-09 23:38
npm config rm proxy
npm config rm https-proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy

Damn finally this does the trick in Debian Jessie with privoxy (ad remover) installed, Thank you :-)

查看更多
仙女界的扛把子
6楼-- · 2019-01-09 23:39

If you go through the npm config documentation, it says:

proxy

Default: HTTP_PROXY or http_proxy environment variable, or null

Type: url

As per this, to disable usage of proxy, proxy setting must be set to null. To set proxy value to null, one has to make sure that HTTP_PROXY or http_proxy environment variable is not set. So unset these environment variables and make sure that npm config ls -l shows proxy = null.

Also, it is important to note that:

  • Deleting http_proxy and https_proxy config settings alone will not help if you still have HTTP_PROXY or http_proxy environment variable is set to something and
  • Setting registry to use http:// and setting strict-ssl to false will not help you if you are not behind a proxy anyway and have HTTP_PROXY set to something.

It would have been better if npm had made the type of proxy setting to boolean to switch on/off the proxy usage. Or, they can introduce a new setting of sort use_proxy of type boolean.

查看更多
甜甜的少女心
7楼-- · 2019-01-09 23:39

By the default value npm is looking for packages from https://registry.npmjs.org. What you also need to do is override the registry and strict-ssl values.

npm config set registry "http://registry.npmjs.org"
npm config set strict-ssl false
查看更多
登录 后发表回答