Skip to content

Instantly share code, notes, and snippets.

@deedubs
Last active August 29, 2015 14:04
Show Gist options
  • Save deedubs/322b1d91006defe19845 to your computer and use it in GitHub Desktop.
Save deedubs/322b1d91006defe19845 to your computer and use it in GitHub Desktop.
curl https://gist.githubusercontent.com/deedubs/322b1d91006defe19845/raw/af74902f15cc5c0b18feea264de37a0b9e4286f9/install-nodejs.sh | bash
#!/bin/sh
CURRENT=$(node -v)
VERSION=$(curl -L -s http://nodejs.org/dist/latest/ \
| egrep -o '[0-9]+\.[0-9]+\.[0-9]+' \
| tail -n1)
PLATFORM=linux
ARCH=x64
PREFIX="/usr/local"
if test "v$VERSION" != "$CURRENT"; then
echo "Installing node v$VERSION ..."
mkdir -p "$PREFIX" && \
curl -# -L http://nodejs.org/dist/v$VERSION/node-v$VERSION-$PLATFORM-$ARCH.tar.gz \
| tar xzvf - --strip-components=1 -C "$PREFIX"
else
echo "Latest stable version of node already installed."
fi

Starting with node v0.8.6, we're gonna be releasing official binary tarballs of the releases for the most common platform+architecture combos.

Here's a simple script that will install the latest stable node using a simple curl | tar piping. By default the files will get installed into your HOME directory. Change the PREFIX variable to /usr/local if you're feeling ambitious (note: you may need to run this as root depending on the PREFIX).

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