Thursday, September 1, 2016

Running Node.js (npm) behind a proxy

At work I've installed and used node.js (npm) several times.  Every time I use npm it generates the following errors when it's first run:
    
    npm ERR! network connect ETIMEOUT
    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 networ 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'

These errors indicate that you Here's how I fixed it. It turns out to be pretty basic. npm uses a series of configuration settings, which can be accessed by using npm config as follows:
  • call npm config list to see all of the current configuration settings
  • call npm config get to retrieve the value a specific configuration setting
  • call npm config delete to remove a specific configuration setting
  • call npm config set to set a value for a specific configuration setting
So to fix my problem behind the firewall, I just needed to run two commands to configure my proxy:

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

No comments:

Post a Comment