Skip to content

Instantly share code, notes, and snippets.

@thomseddon
Last active December 27, 2015 18:19
Show Gist options
  • Save thomseddon/7368814 to your computer and use it in GitHub Desktop.
Save thomseddon/7368814 to your computer and use it in GitHub Desktop.
Install node.js on linux
#!/bin/bash
# Get the latest version no.
version=$(wget --quiet --output-document - \
http://nodejs.org/dist/latest/SHASUMS.txt |
head --lines 1 |
cut --fields 3 --delimiter " " |
cut --fields 2 --delimiter "-")
name=node-$version-linux-x64
# Retrieve
echo Retrieveing $name.tar.gz
wget --output-document /tmp/$name.tar.gz \
http://nodejs.org/dist/$version/$name.tar.gz
# Inflate
tar --gzip --extract --file /tmp/$name.tar.gz --directory /tmp
# Install
echo Installing
cp --recursive --force /tmp/$name/bin/node /usr/bin/node
cp --recursive --force /tmp/$name/lib/node_modules /usr/lib/
ln --symbolic ../lib/node_modules/npm/bin/npm-cli.js /usr/bin/npm
# Cleanup
rm --recursive --force /tmp/node-v*-linux-x64*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment