Skip to content

Instantly share code, notes, and snippets.

@cmmartin
Created April 7, 2015 19:50
Show Gist options
  • Save cmmartin/cd2cdb2858e955c5f87d to your computer and use it in GitHub Desktop.
Save cmmartin/cd2cdb2858e955c5f87d to your computer and use it in GitHub Desktop.
Upgrade node.js using n
#!/bin/bash
# Updates your version of node.js using the version control system "n"
# @param a version (default is latest stable)
# https://github.com/tj/n
sudo npm cache clean -f
sudo npm install -g n
version=`node -v`
if [ $# -gt 0 ]; then
echo "upgrading node from $version to v$1"
sudo n $1
else
echo "upgrading node from $version to latest stable"
sudo n stable
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment