Skip to content

Instantly share code, notes, and snippets.

@schaechinger
Last active November 30, 2018 16:15
Show Gist options
  • Save schaechinger/ad1a45586363bd4469ed5c64e08505c1 to your computer and use it in GitHub Desktop.
Save schaechinger/ad1a45586363bd4469ed5c64e08505c1 to your computer and use it in GitHub Desktop.
Shell script to update / change the installed node version for production use without nvm
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
if [ -z $1 ]; then
echo "Version required (x.y.z)"
exit 1
fi
NODE_VERSION=$1
FILE=node-v$NODE_VERSION-linux-x64.tar.xz
URL=https://nodejs.org/dist/v$NODE_VERSION/$FILE
cd /tmp
wget $URL
cd /usr/local
tar --strip-components 1 -xf /tmp/$FILE > /dev/null
rm /tmp/$FILE
echo "CURRENT NODE VERSION"
node -v
npm i -g npm@latest > /dev/null
echo "CURRENT NPM VERSION"
npm -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment