free software for the blind

What to do when `npm install` hangs?

(updated on Jan 25, 2015)

Nodejs and npm is great but make you annoyed when `npm install` hangs. Here are some tips:

First, turn on log:
npm config set loglevel info
Second, download package with wget. npm usually struck at downloading packages and it's much slower than wget. So when you see it fetching some package for a long time in log, download the package with wget and add the file to npm cahe with following command:
npm cache add xxx.tgz
Then, cancel the npm install command and re-run it again. It will no longer need to download that package any more.