Skip to content

Commit 79adf1b

Browse files
kevinWangShengshenghui kevin
andauthored
fix(install): detect NVM and warn if old Node version is active (#74)
- Add detect_nvm_and_warn() function to check for NVM presence - If NVM is installed with old default Node (< v22), show clear instructions - Prevents confusing installation failures on NVM-managed systems Fixes #24881 Co-authored-by: shenghui kevin <shenghuikevin@shenghuideMac-mini.local>
1 parent 5cfd95b commit 79adf1b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

public/install.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,48 @@ install_node() {
13651365
ui_success "Node.js v22 installed"
13661366
print_active_node_paths || true
13671367
fi
1368+
1369+
# Detect NVM and warn if the active Node is still from NVM with old version
1370+
detect_nvm_and_warn
1371+
}
1372+
1373+
# Detect NVM and warn user if they need to switch Node version
1374+
detect_nvm_and_warn() {
1375+
# Check if NVM is installed (look for NVM_DIR or nvm script)
1376+
local nvm_dir="${NVM_DIR:-}"
1377+
if [[ -z "$nvm_dir" ]] && [[ -f "${HOME}/.nvm/nvm.sh" ]]; then
1378+
nvm_dir="${HOME}/.nvm"
1379+
fi
1380+
1381+
# If NVM not found, nothing to do
1382+
if [[ -z "$nvm_dir" ]]; then
1383+
return 0
1384+
fi
1385+
1386+
# NVM is present - check if current node is from NVM and old
1387+
local node_path
1388+
node_path="$(command -v node 2>/dev/null || true)"
1389+
1390+
if [[ -n "$node_path" && "$node_path" == *".nvm"* ]]; then
1391+
local current_version
1392+
current_version="$(node -v 2>/dev/null || true)"
1393+
local major="${current_version#v}"
1394+
major="${major%%.*}"
1395+
1396+
if [[ -n "$major" && "$major" -lt 22 ]]; then
1397+
ui_warn ""
1398+
ui_warn "⚠️ NVM detected with old default Node version"
1399+
ui_warn " Your shell is using NVM's Node ${current_version}, but OpenClaw requires Node 22+"
1400+
ui_warn ""
1401+
ui_info "To fix this, run:"
1402+
ui_info " nvm install 22"
1403+
ui_info " nvm use 22"
1404+
ui_info " nvm alias default 22"
1405+
ui_warn ""
1406+
ui_warn "Then restart your terminal and run the installer again."
1407+
exit 1
1408+
fi
1409+
fi
13681410
}
13691411

13701412
# Check Git

0 commit comments

Comments
 (0)