npm Runs Out Of Memory and Dies

The Node package manager (npm) is a popular tool for installing programs. Npm is able to manage all the dependencies of the packages you are installing. However, npm does not work on a low memory system. Low cost VPSs would be a great place to run and develop web applications. Currently this is not possible because so many web applications use npm and npm crashes when the amount of memory on the system is too low.

Npm simply dies mid installation and the only message provided is a "Killed" message. No errors or anything else like that.

The only solution given by the npm developer team is to run the

npm install

command on a different, higher memory computer and then copy the node_modules folder over to the low memory machine. This is a rather frustrating way of doing things, but seems to be the only solution other than upgrading to a higher memory VPS or increasing the swap memory of the machine (which is often not possible on a VPS).