Skip to content

Instantly share code, notes, and snippets.

@mikeal
Last active January 28, 2020 03:39
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save mikeal/4eaae8d796c6bf486154 to your computer and use it in GitHub Desktop.
Save mikeal/4eaae8d796c6bf486154 to your computer and use it in GitHub Desktop.
Find and install latest node from source on Ubuntu.
#!/bin/bash
echo "Finding latest version."
VERSION=`curl -s http://nodejs.org/dist/latest/SHASUMS.txt | awk '/node-v/ {print $2}' | head -1 | sed s/node-v// | sed s/-/\ / | awk '{print $1}'`
echo "Preparing to install node-v$VERSION"
url="http://nodejs.org/dist/v"$VERSION"/node-v"$VERSION".tar.gz"
echo "GET" $url
curl $url | tar -zxf -
cd "node-v"$VERSION
# Doing Deps
echo "Installing deps."
# For some reason everything after apt-get requires explicit &&
apt-get -y install build-essential openssl libssl-dev pkg-config &&
echo "Finished deps." &&
# Time to Install
./configure &&
make &&
make install &&
cd .. &&
rm -rf node-v$VERSION &&
node --version &&
exit
curl -s https://gist.githubusercontent.com/mikeal/4eaae8d796c6bf486154/raw/install.bash | bash
@jhs
Copy link

jhs commented May 24, 2014

At line 15, you could add set -e which will exit with an error if any command fails (returns nonzero).

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