How to install NPM behind authentication proxy on Windows?

set http_proxy worked really well for me but I had to enter it in every time I opened the command prompt. So I had to combine multiple answers and now mine is permanent.

My sequence went as follows:

  • Go to C:\Users\YourUserName
  • Create a file named .npmrc
  • Inside that file type the following (if you are on an AD domain):

proxy = http://domain\\username:password@ip:port

  • Or use this is you are NOT on an AD domain:

proxy = http://username:password@ip:port

  • Save the File
  • Open a command prompt and try to use npm

Others have had extra success with the following extra command:

strict-ssl = false

*You should be able to use an IP address or the URL to the proxy in place of "IP" above.

Your proxy string may need to be tweaked a bit, but this made it so that I didn't have to add this every single time.

Cheers


Maybe setting an environment variable will work for you:

set HTTP_PROXY=http://user:[email protected]:port

(In my case, this solves the "connect UNKNOWN", but I get a completely different "socket hang up" error. I also tried setting the HTTPS_PROXY environment variable, but got the same result.)


I had this identical issue and here's what I did to make this work:

  • Go to: C:\Users\YourUserName
  • Create a file named .npmrc
  • And it's entry will read:

    registry = http://registry.npmjs.org
    
  • Try the command node cli.js install npm -gf again.


After some research, I could use it in this way:

  1. Install NTLM Authorization Proxy Server or another proxy server for NTLM, like Cntlm. Personally, I prefer the python server, because I can tinker with it, and performance is not a problem.

  2. Set up the configuration; note that in my case, I had to enable both LM and NT mode, and I would suspect it being the normal case, nowadays.

  3. Set http_proxy and https_proxy environment variable to point to your local proxy:

    set http_proxy="localhost:5865"
    set https_proxy="localhost:5865"

  4. npm should work now, of course it should be executed from a shell where the above environment variables are defined.