1
votes

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:[email protected]: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 '@'

3
Some discussion here: superuser.com/questions/347476/… (includes special reference to the @ character). - morechilli

3 Answers

2
votes

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:[email protected]:8080
npm config set https-proxy http://LanguidSquid:[email protected]:8080

Additional information here: Using npm behind corporate proxy .pac

0
votes

It's simple:

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

EDIT: Sorry didn't read about special chars:

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

http://username:p@[email protected]:8080

you have to write this:

http://username:p%[email protected]:8080
0
votes

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