NPM Proxy Settings

Some times you are not able to download node modules from internet even though you have installed npm and also you are connected to the internet. 

There can be more than one reason behind that issue like : 

  • Required dependencies are not included in package.json
  • Invalid npm registry or blocked registry
  • Organisation Proxy Setting (This is the most common issue) .

Proxy servers are common in college and organisation environment.  so if your internet access is through proxy server than you need to set the proxy for npm

You can check the proxy settings in your browser panel or using Network and Sharing Center in Windows :

Steps to check proxy settings in Chrome :

Open Settings > System > Open Proxy Settings > LAN Settings

In LAN Settings you can find the proxy server and its port no.

Same way in Windows OS you can check proxy settings without any browser :

Open Network & Sharing Center > Internet Options > Open Connection Tab > LAN Settings

Once you get the proxy settings (server name , port , user name and password) you need to configure your npm configuration as below : 

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

You have to change <username>, <password> , <proxy-server-url> and <port> with your proxy settings.

These fields are optional, some times <username> and <password> is not required, if port is 80 than it is not required(it is the default port).

Once proxy configuration is set in npm configuration, run below command

npm install 

You should not have to use npm commands with proxy settings, if either of following happens

  • Your System administrator or Organisation policy does not allow you to access remote npm repositories from npmjs
  • The remote repository of node modules is not in your machine but it’s in the internal network of an organisation

If you like this article and find it interesting or useful - share it
Close Menu