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
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:
- Call ngOnInit() again from another function – Angular 9 ?
- ngOnChanges get new value and previous value – Angular
- Global Angular CLI version is greater than your local version
- Upgrade Angular CLI to the latest version Angular 9 or 10 ?
- How to use new static option in ViewChild Angular 9 ?
- Project contents into angular components using ng-content
- Call ngOnInit() again from another function – Angular 9 ?
- ngAfterContentInit with Example – Angular
- ngAfterViewInit with Example – Angular
- Node Sass could not find a binding for your current environment
- ngOnDestroy Example Angular
- Angular Component : In which lifecycle hook you can check value of DOM element ?
- @ContentChild TypeError: Cannot read property ‘nativeElement’ of undefined
- Access ng-content with @ContentChild – Angular Component
- How to select an element in a component template – Angular ?
- Difference between @ViewChild and @ContentChild – Angular Example
- Expected 0 type arguments, but got 1 : Angular
- Angular – Access template reference variables from component class ?
- Pass variable from parent to custom child component – Angular 9
- Cannot find name ‘Output’ – Angular
- EventEmitter parameter value undefined for listener
- Typescript Error: Property does not exist on value of type
- Remove http and https proxy settings of npm and git ?
- How to remove node.js from Windows completely ?