Last active
December 20, 2015 09:19
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
Usage