issues

NPM Proxy Setting

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
Ankit

Disqus Comments Loading...
Share
Published by
Ankit
Tags: proxy

Recent Posts

Awesome Charts in Angular 13 with ng2-charts

Charts help us to visualize large amounts of data in an easy-to-understand and interactive way.  …

2 years ago

Client-Side PDF Generation In Angular 13 With PDFMake

Generating reports, invoices, blog content, documents, guidelines, forms, etc in PDF form is a common…

2 years ago

Dynamically Add Title and Meta Tags on Route Change in Angular

Web Page title, description, and other meta tags are very important for the Search Engine…

4 years ago

Integrate Google Analytics with Angular | Angular SEO

Google Analytics is a popular analytical tool for web and mobile applications from Google. It…

4 years ago

16 Best Chrome DevTools Tips and Tricks

Chrome DevTools provides amazing features to debug source code, capture element state, update and test…

4 years ago

Data Visualization with ECharts in Angular using ngx-echarts

Angular Charts Series Articles Best Angular Chart Libraries How to use ngx-charts in angular application…

4 years ago