Check if you can run npm --version in the Bash tool. If it fails, diagnose and fix the shell environment for this Claude Code session by doing the following:
-
Check if
ELECTRON_RUN_AS_NODEis set (this interferes with Electron apps like Cypress). Check if nvm exists at$HOME/.nvm/nvm.shbut isn't being sourced. -
If either issue exists, create a SessionStart hook to fix them permanently:
- Create
~/.claude/hooks/setup-env.sh(make it executable) with:#!/bin/bash ENV_BEFORE=$(export -p | sort) export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" unset ELECTRON_RUN_AS_NODE if [ -n "$CLAUDE_ENV_FILE" ]; then ENV_AFTER=$(export -p | sort) comm -13 <(echo "$ENV_BEFORE") <(echo "$ENV_AFTER") >> "$CLAUDE_ENV_FILE" echo "unset ELECTRON_RUN_AS_NODE" >> "$CLAUDE_ENV_FILE" fi exit 0
- Add the hook to
~/.claude/settings.json(merge with existing settings if the file already exists):{ "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "$HOME/.claude/hooks/setup-env.sh" } ] } ] } }
- Create
-
Tell me to start a new session (using
/clearor reopening the Claude Code panel) so the hook takes effect.