Skip to content

Instantly share code, notes, and snippets.

@onur2677
Last active December 9, 2019 07:54
Show Gist options
  • Select an option

  • Save onur2677/1e988e45dd30a422dec7ef24c2f07813 to your computer and use it in GitHub Desktop.

Select an option

Save onur2677/1e988e45dd30a422dec7ef24c2f07813 to your computer and use it in GitHub Desktop.
Install Node.js on Linux by using version number and platform information
read -p "Enter Version (Example: 6.10.1): " VERSION
read -p "Enter Platform (Default: x64): " PLATFORM
if [[ "$PLATFORM" == "" ]]; then
PLATFORM="x64"
fi
FORMAT="tar.gz"
OS="linux"
DIRNAME="node-v${VERSION}-${OS}-${PLATFORM}"
FILENAME="${DIRNAME}.${FORMAT}"
if test -f "$FILENAME"; then
echo "$FILENAME exist"
rm -rf $DIRNAME
else
URL="https://nodejs.org/dist/v${VERSION}/${FILENAME}"
echo "$FILENAME not exist, downloading..."
wget $URL
fi
echo "Extracting... ${FILENAME}"
tar -xzf $FILENAME
cd "${DIRNAME}/"
echo "Installing, please enter your password..."
sudo rm -rf /usr/local/lib/node_modules/npm
sudo cp -R * /usr/local/
echo "Installation Completed !"
echo "Node Version"
node -v
echo "NPM Version"
npm -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment