Problem
On Windows with defaultShell: "bash" in Claude Code settings, the auto-deployed context-mode-cache-heal.mjs SessionStart hook fails with:
Failed with non-blocking status code: node:internal/modules/cjs/loader:1450
Root Cause
The hook is registered in settings.json with a bare node command:
"command": "node C:\Users\shmid\.claude\hooks\context-mode-cache-heal.mjs"
On Windows, when Claude Code uses bash as the default shell, the bare node command may not resolve correctly via PATH. Git Bash (sh.exe) has different PATH resolution than CMD/PowerShell — the Node.js directory (C:\Program Files\nodejs\) is typically added to PATH by CMD profile but may not be available in the bash subprocess spawned by Claude Code for hooks.
Fix
Use an absolute path to node.exe instead of bare node:
"command": "\"C:\Program Files\nodejs\node.exe\" \"C:\Users\shmid\.claude\hooks\context-mode-cache-heal.mjs\""
Suggested Change
In the code that auto-deploys context-mode-cache-heal.mjs and registers the hook in settings.json, replace:
with:
`${process.execPath} ${hookPath}`
process.execPath returns the absolute path to the Node.js executable currently running (e.g. C:\Program Files\nodejs\node.exe), which is guaranteed to exist and be executable. This works cross-platform and avoids PATH-resolution issues regardless of the user's shell configuration.
Environment
- Windows 11 Pro
- Claude Code 2.1.121
defaultShell: "bash" (Git Bash)
- Node.js v25.4.0 installed at
C:\Program Files\nodejs\
- Context-mode 1.0.100
Workaround
Manually edit ~/.claude/settings.json SessionStart hook command to use the absolute node.exe path.
Problem
On Windows with
defaultShell: "bash"in Claude Code settings, the auto-deployedcontext-mode-cache-heal.mjsSessionStart hook fails with:Root Cause
The hook is registered in
settings.jsonwith a barenodecommand:On Windows, when Claude Code uses bash as the default shell, the bare
nodecommand may not resolve correctly via PATH. Git Bash (sh.exe) has different PATH resolution than CMD/PowerShell — the Node.js directory (C:\Program Files\nodejs\) is typically added to PATH by CMD profile but may not be available in the bash subprocess spawned by Claude Code for hooks.Fix
Use an absolute path to
node.exeinstead of barenode:Suggested Change
In the code that auto-deploys
context-mode-cache-heal.mjsand registers the hook insettings.json, replace:`node ${hookPath}`with:
`${process.execPath} ${hookPath}`process.execPathreturns the absolute path to the Node.js executable currently running (e.g.C:\Program Files\nodejs\node.exe), which is guaranteed to exist and be executable. This works cross-platform and avoids PATH-resolution issues regardless of the user's shell configuration.Environment
defaultShell: "bash"(Git Bash)C:\Program Files\nodejs\Workaround
Manually edit
~/.claude/settings.jsonSessionStart hook command to use the absolutenode.exepath.