Last active
December 20, 2022 21:09
-
-
Save CodeMan99/669920f5c0b0600e624239bb7340b204 to your computer and use it in GitHub Desktop.
Tiny scripts for getting & installing node.
This file contains 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
#!/usr/bin/env bash | |
set -e | |
VERSION="$1" | |
OS="linux" | |
ARCH="x64" | |
# ARCH="armv7l" | |
URL="https://nodejs.org/dist/v${VERSION}/node-v${VERSION}-${OS}-${ARCH}.tar.xz" | |
printf "Using download URL: $URL\n\n" | |
read -p "Continue [Y/n]: " CONINTUE | |
if [ "$CONINTUE" = "n" ]; then { | |
exit 1 | |
} fi | |
printf "\n" | |
curl -LOJ "$URL" |
This file contains 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
#!/usr/bin/env bash | |
NODE_VERSION="$1" | |
OS="linux" | |
ARCH="x64" | |
# ARCH="armv7l" | |
NODE_TXZ="node-v${NODE_VERSION}-${OS}-${ARCH}.tar.xz" | |
NPM_VERSION="$2" | |
NPM_PREFIX="$(npm config get prefix)" | |
NODE_MODULES="$NPM_PREFIX/lib/node_modules" | |
# remove npm to avoid breaking changes in the folder structure | |
rm -rf "$NODE_MODULES/npm" | |
tar -C "$NPM_PREFIX" --strip-components=1 -xJf "$NODE_TXZ" | |
[ -z "$NPM_VERSION" ] || npm install -g "npm@${NPM_VERSION}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment