Npm behind a corporate web proxy

One day, I had to start working on phonegap. Upon reading some documentation online, the first thing I understood was to install the phone gap by running the command.

npm install -g phonegap

After a very long pause by a spinning wheel, it showed the following message.

npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

The reason for failure is, not setting the proxy information in the configuration.

Assigning the proxy information can be done as below

npm config set proxy http://proxy.mycompanyname.org:8080
npm config set https-proxy http://proxy.mycompanyname.org:8080

Replace this piece of line http://proxy.mycompanyname.org:8080 with what ever your proxy information is.

To see the config information

npm config list

npm’s config file is typically stored in the user’s profile folder with the extension “.npmrc”

Leave a comment