Skip to content

Instantly share code, notes, and snippets.

@dbehnke
Created April 4, 2017 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbehnke/6d6303d9e4feb197c60125864c266734 to your computer and use it in GitHub Desktop.
Save dbehnke/6d6303d9e4feb197c60125864c266734 to your computer and use it in GitHub Desktop.
Get the latest nodejs/npm binaries and extract and create activate script (Linux 64bit)
#!/bin/bash
getversion() {
curl https://nodejs.org/en/ -o index.html
export version=$(cat index.html | grep Current | tail -n 1 | awk -F' v' '{ print $2 }' | awk -F' Current' '{ print $1 }')
}
cleandownload() {
rm index.html
rm node.tar.xz
}
install() {
getversion
echo $version
curl -o node.tar.xz https://nodejs.org/dist/v${version}/node-v${version}-linux-x64.tar.xz
tar xvfJ node.tar.xz
nodedir=node-v${version}-linux-x64
rm -r -f node
ln -s ${nodedir} node
cat > activate-nodejs.sh <<EOF
#!/bin/bash
export OLDPATH=$PATH
deactivate() {
export PATH=$OLDPATH
unset OLDPATH
}
export OLDPATH=$PATH
export PATH=$PWD/node/bin:$PATH
EOF
chmod +x activate-nodejs.sh
}
install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment