npm and a proxy server

I was just setting up npm to try out Angular and hit the age old problem of accessing the internet through a proxy server.

You can set your proxy servers as follows

npm config set proxy http://<username>:<password>@<proxy>:<port>

and likewise the https proxy as follows

npm config set https-proxy http://<username>:<password>@<proxy>:<port>

This should create the relevant configuration file (.npmrc) in your c:\Users\{username} folder on Windows.

To confirm the location you can simply type

npm config get

Note: type “npm config” to get a list of usage commands.

You can also edit the .npmrc with a text editor, which is the simplest way to update password or the likes for your proxy.