DEV Community

Phil Smith
Phil Smith

Posted on


Troublshooting npm proxy issues part 1

The npm package manager is a must have for JavaScript devs but, sometimes, being on a corporate network means you have to navigate a proxy to access the packages. This is the first post dedicated to troubleshooting npm proxy issues.

If you run, for example, npm install --save-dev grunt on our home network grunt will be installed into your project as expected. If you are running on a network with a proxy server you may get an error like

npm ERR! errno ETIMEDOUT
npm ERR! network request to failed ...

The error text will then go onto to suggest that if you are behind a proxy you must set the 'proxy' config. This means you have to tell npm the address of the proxy on your network.

There's actually two config settings you have to set: proxy and https-proxy, https-proxy being the address for TLS. Let's say that the proxy address is then simply enter

npm config set proxy


npm config set https-proxy

At this point npm should start working, or it might give you a 403 error. Dealing with that 403 error will be the subject part 2.

Additional Stuff

Config settings can be displayed using the folllowing commands. To display a list of the user config settings use npm config ls, all config settings are displayed with npm config ls -l.

This second command will also show you the location of you .npmrc file, which is your userconfig file. You can type your config settings directly into that file and save it instead of using cli commands, if you want too, I prefer the cli. Here's more details on npm config.

Top comments (0)

Visualizing Promises and Async/Await 🤯

async await

☝️ Check out this all-time classic DEV post