From b6cc8b1a8621bafc1e05ffd7f71e73bb48d212b7 Mon Sep 17 00:00:00 2001 From: Bastien Chanot Date: Tue, 23 Jun 2026 14:09:12 +0200 Subject: [PATCH] fix(install): nvm fallback when node/npm missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fresh machine had no npm → install.sh err-exited before the Claude Code CLI install could run. Instead of aborting, bootstrap the current LTS via nvm (v0.39.7) → `nvm install --lts` when node or npm is absent. Keeps the >=18 floor + friendly messages on hard failure. Replaces the reverted lib/install-prereqs.sh centralization with the minimal targeted fix. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01UyNYwD4UccVw9ZCFZyJX55 --- install.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 2233a6b..7187feb 100755 --- a/install.sh +++ b/install.sh @@ -22,8 +22,23 @@ echo "" # ── 1. Check prerequisites ── echo "── Checking prerequisites..." +# node + npm drive the Claude Code CLI install below. On a fresh machine +# they may be absent — install the current LTS via nvm instead of aborting. +install_node_via_nvm() { + info "Node.js/npm missing — installing LTS via nvm..." + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash + export NVM_DIR="${NVM_DIR:-$HOME/.nvm}" + # shellcheck source=/dev/null + [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" + nvm install --lts +} + +if ! command -v node &>/dev/null || ! command -v npm &>/dev/null; then + install_node_via_nvm +fi + if ! command -v node &>/dev/null; then - err "Node.js not found. Install it first: https://nodejs.org" + err "Node.js install failed — install it manually: https://nodejs.org" fi NODE_MAJOR=$(node -v | sed 's/v//' | cut -d. -f1) @@ -33,7 +48,7 @@ fi ok "Node.js $(node -v)" if ! command -v npm &>/dev/null; then - err "npm not found" + err "npm not found (expected alongside Node.js)" fi ok "npm $(npm -v)"