2

I have installed node.js in my windows machine which is in a corporate network. So i will have to use my Id and password to access internet through the proxy server.

I have read that we can use npm config set proxy to set the proxy.

npm config set proxy http://ABC\\123456:password@proxy.ABC.com:6050

I have tried it and is not working.

How can i specify the proxy details including username and password in NPM??

My user name is domain\username and password has special characters '!' and '@'

Andromeda
  • 12,659
  • 20
  • 77
  • 103
  • Some discussion here: http://superuser.com/questions/347476/how-to-install-npm-behind-authentication-proxy-on-windows (includes special reference to the @ character). – morechilli Jun 15 '15 at 10:44
  • Possible duplicate of [Using npm behind corporate proxy .pac](http://stackoverflow.com/questions/25660936/using-npm-behind-corporate-proxy-pac) – Blake Yarbrough Feb 29 '16 at 17:32

3 Answers3

2

First open a command console at the location of your npm installation.

Then you can configure your npm to use a proxy using the commands:

npm config set proxy http://{url}:{port}
npm config set https-proxy http://{url}:{port}

Notice the protocol is set to http for both the proxy and https-proxy variables.

If you would like npm to store your credentials for the proxy, you can additionally modify the commands as follows:

npm config set proxy http://{username}:{passphrase}@{url}:{port}
npm config set https-proxy http://{username}:{passphrase}@{url}:{port}

For example:

npm config set proxy http://LanguidSquid:Password1@my.company.com:8080
npm config set https-proxy http://LanguidSquid:Password1@my.company.com:8080

Additional information here: Using npm behind corporate proxy .pac

Community
  • 1
  • 1
Blake Yarbrough
  • 2,286
  • 1
  • 20
  • 36
0

It's simple:

npm config set proxy http://username:password@proxy.company.com:8080

EDIT: Sorry didn't read about special chars:

You have to encode the special characters. E.g. instead of this:

http://username:p@ssword@proxy.company.com:8080

you have to write this:

http://username:p%40ssword@proxy.company.com:8080
michelem
  • 14,430
  • 5
  • 50
  • 66
  • I have already tried it. But it is not working.Still getting ECONNREFUSED error. – Andromeda Jun 16 '15 at 06:29
  • Hi @Andromeda, I am facing the same issue right now, do you still remember how you fixed at the end. Is that two commands working? I am running the above two commands also not working. – Ethan Jul 27 '20 at 14:28
0

Open an command prompt or terminal session and run the following commands to configure npm to work with your web proxy. The commands use proxy.company.com as the address and 8080 as the port.

npm config set proxy http://proxy.company.com:8080

npm config set https-proxy http://proxy.company.com:8080

Community
  • 1
  • 1