Fix Node.js install — upgrade if version < 20
Install script now detects existing Node.js < 20 and upgrades it instead of skipping. Supports apt, dnf, and apk package managers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -42,14 +42,28 @@ fi
|
||||
|
||||
# ─── Node.js ──────────────────────────────────────────────────────────
|
||||
|
||||
if ! command -v node &>/dev/null; then
|
||||
log "Installing Node.js 20..."
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - >/dev/null 2>&1
|
||||
sudo apt-get install -y -qq nodejs >/dev/null
|
||||
NODE_VER=0
|
||||
if command -v node &>/dev/null; then
|
||||
NODE_VER=$(node -v | cut -d. -f1 | tr -d v)
|
||||
fi
|
||||
|
||||
if [[ $NODE_VER -lt 20 ]]; then
|
||||
log "Installing Node.js 20 (found: ${NODE_VER:-none})..."
|
||||
if command -v apt-get &>/dev/null; then
|
||||
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - >/dev/null 2>&1
|
||||
sudo apt-get install -y -qq nodejs >/dev/null
|
||||
elif command -v dnf &>/dev/null; then
|
||||
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash - >/dev/null 2>&1
|
||||
sudo dnf install -y -q nodejs
|
||||
elif command -v apk &>/dev/null; then
|
||||
sudo apk add --no-cache nodejs npm
|
||||
else
|
||||
err "Cannot install Node.js 20+. Install it manually."
|
||||
fi
|
||||
fi
|
||||
|
||||
NODE_VER=$(node -v | cut -d. -f1 | tr -d v)
|
||||
[[ $NODE_VER -lt 20 ]] && err "Node.js 20+ required, found $(node -v)"
|
||||
[[ $NODE_VER -lt 20 ]] && err "Node.js 20+ required, found $(node -v). Install manually."
|
||||
log "Node.js $(node -v) OK"
|
||||
|
||||
# ─── Firecracker ──────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user