npm install : Killed (Ubuntu 16.04)

Posted on Feb 21, 2018

While installing packages via npm, it failed with just the message “Killed”. Automatically this triggers me to believe it is memory related. I was after all running the VM with only 1G memory.

Fix npm install Killed

So to resolve this, you need to create and extend a swap file.

You can do this in Ubuntu 14.04 and 16.04 with the following commands:

sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile sudo swapon –show sudo cp /etc/fstab /etc/fstab.bak echo ‘/swapfile none swap sw 0 0’ | sudo tee -a /etc/fstab sudo sysctl vm.swappiness=10 echo ‘vm.swappiness=10’ | sudo tee -a /etc/sysctl.conf sudo sysctl vm.vfs_cache_pressure=50 echo ‘vm.vfs_cache_pressure=50’ | sudo tee -a /etc/sysctl.conf

As always, I hope this helps anyone else with the same issue!