Skip to content

Instantly share code, notes, and snippets.

@HashNuke
Last active November 29, 2015 08:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HashNuke/3961b4f780d068032411 to your computer and use it in GitHub Desktop.
Save HashNuke/3961b4f780d068032411 to your computer and use it in GitHub Desktop.
node-gyp on small servers

node-gyp on small servers

node-gyp needs more ram or swap space to install. Use these commands to create swap space as root. (if using sudo, then put the following in a file and then run it using sudo).

Assumes you have Ubuntu. Should work for most Debian-based OSes.

These are quick copy-paste commands to create 2gb swap space. Look at the end for info.

# feel free to change below values
export SWAP_PATH=/swap
export SWAP_SIZE=2097K

touch $SWAP_PATH
chmod 0600 $SWAP_PATH

dd if=/dev/zero of=$SWAP_PATH bs=1024 count=$SWAP_SIZE
mkswap $SWAP_PATH
swapon $SWAP_PATH
echo "$SWAP_PATH  none  swap  sw  0  0" >> /etc/fstab
echo 10 | tee /proc/sys/vm/swappiness
echo "vm.swappiness = 10" | tee -a /etc/sysctl.conf

then as a user that uses npm, run following:

npm config set jobs 1

info

  • SWAP_PATH is the path to create the swap
  • SWAP_SIZE is the size of the swap. We set it at around 2gb
    • swap size in 1kb blocks
    • 2048mb * 1024kb == 2097152
    • which is approximately 2097 thousand ( == 2097k)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment