Cpp
This commit is contained in:
@@ -1,43 +1,45 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Path: scripts/node.sh
|
||||
|
||||
set -e
|
||||
|
||||
BLUE='\033[1;34m'
|
||||
YELLOW='\033[1;33m'
|
||||
GREEN='\033[1;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
# 1. Define Custom Path
|
||||
# 1. Define Custom Path (The Black Box)
|
||||
export NVM_DIR="$HOME/.programming/node"
|
||||
|
||||
echo -e "${BLUE} LOG:${YELLOW} Setting up Node.js (NVM)...${NC}"
|
||||
echo -e "${BLUE} LOG:${YELLOW} Setting up Node.js (NVM) in ${NVM_DIR}...${NC}"
|
||||
|
||||
# 2. Install NVM (if missing)
|
||||
if [ ! -d "$NVM_DIR" ]; then
|
||||
mkdir -p "$NVM_DIR"
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing NVM to custom path...${NC}"
|
||||
|
||||
# PROFILE=/dev/null prevents the installer from editing your .zshrc/.bashrc
|
||||
# NVM_DIR is exported above, so the install script picks it up automatically.
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | PROFILE=/dev/null bash
|
||||
fi
|
||||
|
||||
# 3. Source NVM (Load it into current shell)
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
|
||||
# 4. Install Node
|
||||
if command -v nvm &> /dev/null; then
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing LTS...${NC}"
|
||||
nvm install --lts
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing Node LTS...${NC}"
|
||||
|
||||
# --no-progress suppresses the progress bar spam in logs
|
||||
nvm install --lts --no-progress
|
||||
nvm use --lts
|
||||
|
||||
echo -e "${BLUE} LOG:${YELLOW} Installing Global Tools...${NC}"
|
||||
echo -e "${BLUE} LOG:${YELLOW} Enabling Corepack (pnpm/yarn)...${NC}"
|
||||
|
||||
# Disable strict error checking for npm global installs (they are noisy)
|
||||
set +e
|
||||
npm install -g pnpm yarn || true
|
||||
set -e
|
||||
corepack enable
|
||||
|
||||
echo -e "${GREEN} LOG: Node setup complete. $(node -v)${NC}"
|
||||
echo -e "${GREEN} LOG: Package Managers: pnpm $(pnpm -v), yarn $(yarn -v)${NC}"
|
||||
else
|
||||
echo -e "${RED} ERROR: NVM failed to load from $NVM_DIR${NC}"
|
||||
exit 1
|
||||
|
||||
Reference in New Issue
Block a user