Skip to content

fix: Windows bash shell — auto-deployed hook fails with bare node command (cjs/loader:1450) #369

@ShmidtS

Description

@ShmidtS

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:

`node ${hookPath}`

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions