326

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?

1
  • 7
    You can manually delete proxy settings from <user_dir>/.npmrc file
    – Salman
    Commented Jan 20, 2014 at 10:38

37 Answers 37

527

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

3
  • Works on windows Commented Apr 2, 2019 at 7:59
  • 6
    Can use npm config list to check the proxy config, maybe npm config rm http-proxy is needed, too
    – Tina Chen
    Commented Aug 17, 2019 at 9:42
  • @Anatolii has an answer for cleaning up global configuration settings below. The rm parameter doesn't work on old versions of npm for Windows -- see @Aaron's answer below.
    – dan
    Commented Mar 10, 2020 at 19:37
158

Try deleting them with:

npm config delete proxy
npm config delete https-proxy
3
  • It outputs the same warning.
    – Allan Ruin
    Commented Apr 11, 2014 at 5:04
  • 7
    shouldn't it be npm config delete proxy?
    – Frank Fu
    Commented Aug 15, 2014 at 13:03
  • 6
    This work on windows. Try npm config rm http-proxy on linux
    – Sydwell
    Commented Jun 14, 2015 at 18:18
49
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 :-)

2
  • This was the correct solution on OSX 10.11, tried everything else
    – Shooky
    Commented Mar 24, 2017 at 13:12
  • This solution works but doesn't seem to stick, after logout / reboot I had the same issue again. Can anyone explain where these variables are getting set? @privoxyd
    – Shooky
    Commented Apr 6, 2017 at 16:05
44

This was already answered but I think the --global config is not covered properly.

By running npm config rm proxy you remove proxy from user configuration.
This can be easily verified by running: npm config list.

If there is proxy or https-proxy setting set in global config you have to use --global in the command to remove it.

So at the end this will clean-up proxies from both local and global configs:

npm config rm proxy
npm config rm https-proxy
npm config --global rm proxy
npm config --global rm https-proxy
1
  • 3
    This --global thing did the trick for me while just removing from the user configuration had no effect. Running on an old NPM version though. #thanksanatolii
    – Matti.b
    Commented May 10, 2019 at 7:42
31

In the latest version npm rm proxy does not work. Instead use npm rm http-proxy

npm config rm proxy npm config rm https-proxy

30

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
2
  • This is a nice solution to overcome the whole issue of npm behind proxies.
    – markau
    Commented Oct 29, 2014 at 1:49
  • Thanks for this solution! Commented Apr 11, 2021 at 16:22
22

I have used the below commands for removing any proxy set:

    npm config rm proxy
    npm config rm https-proxy

And it solved my problem :)

21

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.

5
  • 3
    This helped me, all the other suggestions (delete & rm) only remove https-proxy & proxy settings for your local npm config - not the default, by setting null it overrides these default settings Commented Jan 9, 2015 at 9:59
  • npm 3 does not honor --proxy=null anymore, does anyone know details?
    – C-Otto
    Commented Jul 14, 2016 at 10:37
  • 3
    To answer my own question, --no-proxy seems to work
    – C-Otto
    Commented Sep 19, 2016 at 7:33
  • @C-Otto Thank you so much for writing the only answer that worked after hours of banging my head! Commented Oct 23, 2016 at 4:22
  • @C-Otto Thank you so much. This is the only solution which worked for me. I tried hundreds of other solution but nothing worked. '--no-proxy' did the trick. But do you know why does it pick old proxy settings without '--no-proxy' option and from where? Commented Feb 14, 2019 at 14:54
17

there is a simple way of deleting or removing the npm proxies.

npm config delete proxy
npm config delete https-proxy
17

I had the same problem once.
Follow these steps to delete proxy values:

1.To delete proxy in npm:
(-g is Important)
npm config delete proxy -g
npm config delete http-proxy -g
npm config delete https-proxy -g

Check the npm config file using:
npm config list

2.To delete system proxy: set HTTP_PROXY=null set HTTPS_PROXY=null

Now close the command line and open it to refresh the variables(proxy).

15

Nothing above worked for me. I had to edit the file ".npmrc" which will be under user home directory (ex: c:\users\abcuser) :

http_proxy=null
registry=https://registry.npmjs.org/
strict-ssl=true
proxy=null
3
  • 3
    This Worked for me... To remove proxy we have to change registry as registry.npmjs.org and strict-ssl as true
    – Vicky
    Commented May 15, 2017 at 11:27
  • I am trying this out to see if my project specific .npmrc setting for proxy will override any global settings in the user's home dir which clobber us in a shared build environment.
    – httpete
    Commented Aug 28, 2019 at 15:35
  • I updated my project .nprmc file. It did not work Commented Oct 12, 2021 at 16:23
14

This works

npm config delete http-proxy
npm config delete https-proxy

npm config rm proxy
npm config rm https-proxy

set HTTP_PROXY=null
set HTTPS_PROXY=null
13

Running npm version 2.10.1 in windows 7, I used:

npm config delete proxy
npm config delete https-proxy
11

Try This,

npm config delete http-proxy

npm config delete https-proxy

npm config rm proxy

npm config rm https-proxy

set HTTP_PROXY=null

set HTTPS_PROXY=null

1
  • If you're using bash (Linux, or Window Git bash), try export HTTP_PROXY= and export HTTPS_PROXY= rather than set ...=null
    – cmousset
    Commented Jul 19, 2021 at 17:15
10

The easiest way to remove any configuration at all from npm is to edit the npm config file. It only takes two(2) commands to do this; one to open npm config file for editing, the other to confirm your change.

  1. type npm config list to view a list of all npm configurations that are active.
  2. type npm config edit to open a text editor with npm configurations. To remove the proxy line ( or simply comment it out ).
  3. Save the config file and close it.
  4. type npm config list to confirm that the proxy configuration has been removed.

C'est la vie!

I tried everything listed on this page, none worked, then I tried to the config edit. It worked instantly. (I use Windows 10)

1
  • @Madhan it is the Swiss Army knife for npm configuration Commented Apr 1, 2017 at 6:59
8
npm config delete proxy -g

worked for me.

-g was important as initially it was set with that option. You can check configurations set with :

npm config list
1
  • npm write config also on ./etc
    – venergiac
    Commented Nov 26, 2016 at 8:06
6
npm config rm proxy
npm config rm https-proxy

Worked for me

5

I think it's not http-proxy but proxy:

npm config set proxy="http://yourproxyhere"
1
  • It always showed npm ERR! If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config' None of the other options worked. This one worked best.
    – Shiyaz
    Commented Jul 15, 2015 at 9:33
3

Got exactly the same problem, I keep seeing my proxy configuration even after removing the npmrc file and deleting the keys.

I found out that npm were using windows env key http-proxy by default.

So go in Computer->Properties->Advanced system settings->Environement variables and check there is no http-proxy key configured.

1
  • Interesting, I checked the environment variables and I don't have things like http-proxy. Maybe the warning is really neglectable.
    – Allan Ruin
    Commented Apr 11, 2014 at 5:06
3

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
    
3

See the npm Settings in file C:\Users\myusers.npmrc file. Sometime the npm proxy config settings does not apply. so its worth checking in there.

3
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

If you want to switch between proxy for company network and remove proxy for home/personal network you can use --no-proxy

Sample usage:

npm install --save-dev "@angular/[email protected]" --no-proxy
2

execute npm config list it will list down all proxy values.. in my case proxy value was fetched form global npmrc file, removed it and was able to complete npm install on my windows machine

1
  • I removed proxy in Global .nprmc . I started getting 407 Error. I was behind corporate proxy Commented Oct 12, 2021 at 18:26
2

Well, I'm gonna leave this here because I was having a big trouble with NPM.

I was trying to change a proxy setting using npm config set proxy "http://.../" and then running npm config get proxy. It was ALWAYS returning a wrong value, different from the one that I'd set.

I found out that I had a .npmrc COMMITED on the project I was trying to run npm install and that this file was overriding my own config.

So it was cleaning the proxy value, but I needed to also change the .npmrc inside the folder's project.

After that, everything worked fine.

1

I've used

npm config set proxy null
npm config set https-proxy null

and it worked for me.

Best regards

1

this works for me fime

proxy=http://<username>:<pass>@proxyhost:<port>

https-proxy=http://<uname>:<pass>@proxyhost:<port>

sample in my instance username:uname and password:pword

npm config set proxy=http://uname:[email protected]:8080

npm config set https-proxy=http://uname:[email protected]:8080
1
  • This is setting, we are looking for clear which is exact opposite Commented May 2, 2019 at 8:36
1

I was struggling with this for ages. What I finally did was go into the .npmrc file (which can be found in the user's directory followed by the user's name, ie. C:\Users\erikj/.npmrc), opened it with a text editor, manually removed any proxy settings and changed the http:// setting to https://. In this case, it is a matter of experimenting whether http or https will work for you. In my case, https worked. Go figure.

1

In my case, (windows OS), after put all those commands listed, npm kept taking the proxy in the setting of windows registry

\ HKEY_CURRENT_USER \ Environment

just remove the proxy settings there, after that, I restarted the pc and then "npm install" worked for me

Example

0
1

First, type:

npm config get

If you see any config about a proxy, you can delete that with the name of its key. In my case I had a line: registry = "http://172.16.10.54:4777" I deleted it with the command:

npm config delete registry

And that worked fine!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.