Setting Up npm Proxy in a Corporate Network

October 01, 2019

2019 10 01

Working behind a corporate network can be challenging, as many things do not work "out of the box." A simple command like npm install might not function properly. Here's how to work through the proxy:

Assuming you've somehow managed to install node.js on your corporate laptop, locate the .npmrc file. On Windows, this is typically located at C:\Users\<your_user_id>\.npmrc, and on a Mac, it's at Users/<your_user_id>/.npmrc.

Open the file and add the following lines:

    https-proxy=http://yourcompanyproxy.com:80
    proxy=http://yourcompanyproxy.com:80
    strict-ssl=false
    registry=http://registry.npmjs.org/

Try running npm install again; it should work now!

Here's an additional tip: if you have some dependencies hosted in your corporate internal Nexus npm repository—let's say in the @npmcorp scope—run the following command to specify the correct registry URL:

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

By doing this, you should be able to resolve any "dependency not found" errors. Give it a try!


Profile picture

Victor Leung, who blog about business, technology and personal development. Happy to connect on LinkedIn