Make npm install command to work behind proxy

How to make npm install command to work behind proxy ?

This tutorial guides you on how to make npm install command to work behind proxy. You will learn how to configure proxy settings in your desktop that was setup by your corporate or workplace.

Make npm install command to work behind proxy

Make npm install command to work behind proxy

I had received a laptop from my organization to work from home due to COVID situation. And as I don’t have VPN configured yet, I tried to connect to my home network.

After connecting my office laptop to my home network I tried running npm install command. It resulted with following error.

> npm install

npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
----
----

Then I figured out that this npm install issue was due to proxy server settings i.e., to make npm install command to work behind proxy (corporate proxy). You need to follow the below steps in order to fix this kind of npm install issues in your office laptop.

Fix: npm install behind proxy

As a first step, you need to find out the corporate proxy server host and port details for http and https as shown below.

To find http_proxy details, try running the following echo command.

$ echo $http_proxy
http://<corporate-proxy-server-address>:80

Similarly, check for https_proxy details.

$ echo $https_proxy
https://<corporate-proxy-server-address>:80

Finally to make npm install command to work or resolve npm proxy settings issues, you need to update the npm configuration settings using npm config command. Therefore, you need to run the following two commands.

These commands will configure a proxy server for a specific domain in npm config if you’re having trouble in downloading and installing node modules.

> npm config set proxy http://<corporate-proxy-server-address>:80
> npm config set https-proxy https://<corporate-proxy-server-address>:80

After updating your company’s or corporate’s http and https proxy server address in your npm configuration, try running npm install command. Now you should not see any proxy related issues.

This is how I solved npm proxy issues while I faced the error.

Hope it helped 🙂

Also see:

References:

guest
0 Comments
Inline Feedbacks
View all comments