Skip to content

Instantly share code, notes, and snippets.

@fform
Last active December 20, 2015 09:19
Show Gist options
  • Save fform/6107238 to your computer and use it in GitHub Desktop.
Save fform/6107238 to your computer and use it in GitHub Desktop.
Auto download and install node based on specified version. Tested on Ubuntu 12 x64
if [ "$1" == "" ]; then
echo "You need to specify version like 0.10.0.15"
exit
fi
nodev="node-v$1-linux-x64"
package="$nodev.tar.gz"
echo "Downloading to $1"
wget "http://nodejs.org/dist/v$1/node-v$1-linux-x64.tar.gz"
if [ -f "$package" ]; then
echo "Downloaded"
else
echo "Bad version?"
exit
fi
echo "Unpacking..";
tar -xf $package
echo "Moving into place..";
mkdir -p /usr/local/bin
cp "./$nodev/bin/node" /usr/local/bin/node
cp "./$nodev/bin/npm" /usr/local/bin/npm
mkdir -p /usr/local/lib/node_modules
cp -R ./"$nodev/lib/node_modules/npm" /usr/local/lib/node_modules/npm
chown -R nobody:root /usr/local/lib/node_modules/npm
echo "Cleaning up..."
rm -rf "./$nodev"
rm $package
@fform
Copy link
Author

fform commented Jul 29, 2013

Usage

./update-node.sh 0.10.15

@fform
Copy link
Author

fform commented Jul 29, 2013

Auto selects linux 64bit because I'm always using ubuntu 64bit. Zero error checking, super-fast when it all goes right. Already had a version of node installed so this probably won't work fresh without making /usr/local/lib/node_modules first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment