Setup npm proxy in a corporate network

October 01, 2019

It’s painful to work behind a corporate network and everything does not work out of the box. Simple command like npm install would not work and here is how to work through the proxy:

Assuming you somehow get nodejs installed in your corporate laptop, open the .npmrc file which typical in the path for windows C:\Users\<your_user_id>\.npmrc or mac Users/<your_user_id>/npmrc

Edit the file with this:

https-proxy= proxy= strict-ssl=false registry=

Try to run npm install again it should work now!

One more tip if you have some dependency hosted in your corperate internal Nexus npm repository, for example in the @ npmcorp scope, then run the below command to nominate the correct registry URL:

npm config set @npmcorp:registry https://your-company-nexus:80/nexus/content/repository/npm-internal

Then you should be able to overcome dependency not found errors. Try it out :)

Written by Victor Leung who is a keen traveller to see every country in the world, passionate about cutting edge technologies. Follow me on Twitter