Proxy servers are common in college and business type environments.
You can locate your proxy settings from your browser’s settings panel.
Using Proxy with NPM
Once you have obtained the proxy settings (server URL, port, username and password); you need to configure your
npm configurations as follows.
$ npm config set proxy http://<username>:<password>@<proxy-server-url>:<port> $ npm config set https-proxy http://<username>:<password>@<proxy-server-url>:<port>
You would have to replace
<port> with the values specific to your proxy server credentials.
These fields are optional. For instance, your proxy server might not even require
<password>, or that it might be running on port 80 (in which case
<port> is not required).
Once you have set these, your
npm i -g etc. would work properly.
When Not to Use
You should not have to use
npm commands with proxy settings, if either of the following happens:
- Your system administrator or corporate policy does not allow you to access remote
npmrepositories from NPM-JS, for instance.
- The remote repository of Node modules in question is not in your machine, but it’s within the internal network.
Unset Proxy Settings
You may use the following resources for further reading on this:-