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! code ETIMEDOUT npm ERR! errno ETIMEDOUT npm ERR! network request to https://registry.npmjs.org/grunt 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 http://proxy.example.com:8080 then simply enter
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080
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.
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)