Breaking it down
This commit is contained in:
33
scripts/node.sh
Normal file
33
scripts/node.sh
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
set -e # Exit on error
|
||||
BLUE='\033[1;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
GREEN='\033[1;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE} LOG:${YELLOW} Setting up Node.js (NVM)...${NC}"
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
|
||||
# 1. Install NVM
|
||||
if [ ! -d "$NVM_DIR" ]; then
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
||||
fi
|
||||
|
||||
# 2. Load NVM
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
|
||||
# 3. Install Node
|
||||
if command -v nvm &> /dev/null; then
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing LTS...${NC}"
|
||||
nvm install --lts
|
||||
nvm use --lts
|
||||
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing Global Tools...${NC}"
|
||||
# set +e is safer for npm global installs which can be noisy
|
||||
set +e
|
||||
npm install -g pnpm yarn
|
||||
set -e
|
||||
|
||||
echo -e "${GREEN} LOG: Node setup complete.$(node -v)${NC}"
|
||||
fi
|
||||
Reference in New Issue
Block a user