Last active
December 9, 2019 07:54
-
-
Save onur2677/1e988e45dd30a422dec7ef24c2f07813 to your computer and use it in GitHub Desktop.
Install Node.js on Linux by using version number and platform information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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