npm hangs on postinstall / unlock

chmanie picture chmanie · Mar 11, 2015 · Viewed 10.9k times · Source

I have a Linux server that runs some virtual Machines using KVM. Host machine is a Debian derivate with kernel 2.6.32-32(-pve).

In roughly 75% of the times I run npm install, it hangs while installing modules. I ran it in silly debug level and it always hangs at the line

npm info postinstall [module name] (older npm versions)

or

npm verb unlock done using [...] (newer npm versions)

forever.

It happens in every project on the host machine and on the virtualized systems for every node and every npm version I have tested (a lot, including the newest ones (2.7.x atm)).

It also is not deterministic. Sometimes it works, sometimes not and most of the times it hangs on a different module.

On my dev machine (which is in the same network, running OS X 10.10) it works fine.

I am not behind any kind of proxy.

What could possibly be wrong here?

EDIT: For the time being I solved this problem by checking in all my dependencies as gzipped files using https://github.com/JamieMason/shrinkpack

Answer

David C picture David C · May 3, 2015

I was having the same issue for several hours, and couldn't work out what the problem was. I tried re-installing everything a few times, manually installing individual modules, switching from x64 to x86 versions of NodeJS, etc, and got nowhere.

In the end, I changed networks, from WiFi over ADSL2+ [~2mbps] to 4G Hotspot [~20mbps] and it worked in 30 seconds. No idea why, since it didn't seem like a network speed issue, but it solved the problem.

Hope this helps someone else, too!