How to install NPM behind authentication proxy on Windows

node.jsPROXY

I need to run the latest version of Node and NPM on Windows. I installed Node 0.5.8 and downloaded the sources of NPM from GitHub. The steps I followed to install NPM were listed on its GitHub site but I have a problem running the following command:

node cli.js install npm -gf

but it fails with the following error message:

Error: connect UNKNOWN
at errnoException (net_uv.js:566:11)
at Object.afterConnect [as oncomplete] (net_uv.js:557:18)

System Windows_NT 5.1.2600
command "...\\Node\\bin\\node.exe" "...\\npm\\cli.js" "install" "npm" "-gf"
cwd ...\npm
node -v v0.5.8
npm -v 1.0.94
code UNKNOWN

I think that this is a problem because I need authentication at my proxy to connect to the Internet. But I found no way to tell the installer to use my credentials for login. Is there a possibility to provide my proxy IP and login information to npm installation maybe via command-line arguments?

I can provide the full log (but seems to have no more relevant information) using pastebin if needed.

Best Answer

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

Related Question