fix(install): upgrade existing Node on macOS and use node@22 consistently

- Use 'brew upgrade node@22 || brew install node@22' so existing older Node is upgraded
- Add node@22 bin to PATH after install so node/npm are found
- Align error message with node@22 (was suggesting node@22 while install used node)

Made-with: Cursor
This commit is contained in:
Claude Thebot
2026-02-28 06:39:51 -08:00
parent ca833d2d5c
commit ee1bec0525

View File

@@ -522,7 +522,10 @@ ensure_nodejs() {
fi fi
if [[ "$PLATFORM" == "darwin" ]]; then if [[ "$PLATFORM" == "darwin" ]]; then
brew install node brew upgrade node@22 2>/dev/null || brew install node@22
if [[ -d "$(brew --prefix node@22 2>/dev/null)/bin" ]]; then
export PATH="$(brew --prefix node@22)/bin:$PATH"
fi
if ! command_exists node || ! command_exists npm; then if ! command_exists node || ! command_exists npm; then
die 'Node.js/npm installation failed. Ensure Homebrew bin is in PATH (e.g. eval "$(brew shellenv)").' die 'Node.js/npm installation failed. Ensure Homebrew bin is in PATH (e.g. eval "$(brew shellenv)").'
fi fi
@@ -531,7 +534,7 @@ ensure_nodejs() {
node_major="${node_version#v}" node_major="${node_version#v}"
node_major="${node_major%%.*}" node_major="${node_major%%.*}"
if [[ ! "$node_major" =~ ^[0-9]+$ ]] || ((node_major < 22)); then if [[ ! "$node_major" =~ ^[0-9]+$ ]] || ((node_major < 22)); then
die "Detected Node.js $node_version. Node.js >= 22 is required. Install with: brew install node@22 and link or adjust PATH." die "Detected Node.js $node_version. Node.js >= 22 is required. Install with: brew install node@22 and ensure $(brew --prefix node@22 2>/dev/null || echo '/opt/homebrew/opt/node@22')/bin is in PATH."
fi fi
return return
fi fi