Tag Archives: npm

How to use node.js and npm behind a company firewall

This morning at work I tried to get YUIDoc up and running using the standard node.js npm install approach. At work we are behind a proxy which means you have to manually edit the node.js config.

The Error

If you get an error similar to this you’re probably being blocked by the company firewall.

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'
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "-g" "install" "yuidocjs"
npm ERR! cwd C:\Users\mfasani\Documents
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\mfasani\Documents\npm-debug.log
npm ERR! not ok code 0

The Fix

It’s easy to fix the above problem assuming it’s your company’s firewall causing the issue. Speak to the network team and find out the details of your work's proxy server. Then edit the node.js config as follows:

npm config set proxy http://proxy-server-address:8080
npm config set https-proxy http://proxy-server-address:8080

Now you should be able to continue using the npm to install your packages as normal.