Skip to content

Instantly share code, notes, and snippets.

@BobRupholdt
Last active May 26, 2017 02:40
Show Gist options
  • Save BobRupholdt/0a2a43201c4f93d81e78 to your computer and use it in GitHub Desktop.
Save BobRupholdt/0a2a43201c4f93d81e78 to your computer and use it in GitHub Desktop.
Adding swap file on DigitalOcean 512mb Ubuntu droplet so npm install will complete
# check for swapfile
sudo swapon -s
# if there is one
# swapoff -a
sudo dd if=/dev/zero of=/swapfile bs=1024 count=1024k
sudo mkswap /swapfile
sudo swapon /swapfile
#swapfile should show now with
swapon -s
# set swappiness to keep the server happy
echo 10 | sudo tee /proc/sys/vm/swappiness
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf
# npm install should work fine now
# reboot your droplet so the changes aren't permanent
# any server with SSD drives doesn't like swap files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment