Hooks: Windows backslash paths broken in 2.1.47 - Module not found

Resolved 💬 2 comments Opened Feb 19, 2026 by mgrr Closed Feb 19, 2026

Bug Description

After upgrading to Claude Code 2.1.47, all hooks using Windows backslash paths in settings.json fail with Module not found.

Environment

  • Claude Code version: 2.1.47
  • Platform: Windows 10 (MINGW64/Git Bash)
  • Runtime: Bun 1.3.5
  • Shell: bash (MINGW64_NT-10.0)

Steps to Reproduce

  1. Configure a hook in ~/.claude/settings.json with a Windows-style path:
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "bun C:\Users\username\.claude\scripts\hooks\my-hook.ts"
          }
        ]
      }
    ]
  }
}
  1. Start a Claude Code session
  2. Trigger any tool call that matches the hook

Expected Behavior

The hook should execute normally (as it did in previous versions). The JSON-escaped \ should resolve to \ in the command string, and the path should be valid.

Actual Behavior

Every hook fails with:

PreToolUse:Bash hook error

SessionEnd hooks show the full error:

SessionEnd hook [bun C:\Users\username\.claude\scripts\hooks\my-hook.ts] failed: 
error: Module not found "C:Usersusernameclaudescriptshooksmy-hook.ts"

The backslashes are completely stripped from the path before it reaches bun, turning C:\Users\username\.claude\ into C:Usersusernameclaude.

Root Cause

It appears that between 2.1.46 and 2.1.47, the hook runner changed how it passes command strings to the shell. The backslashes in the command are now being consumed as escape characters before reaching the target executable.

Workaround

Replace all backslash paths with forward slashes in settings.json:

"command": "bun C:/Users/username/.claude/scripts/hooks/my-hook.ts"

Forward slashes work on MINGW/Windows with both bun and node.

Impact

  • All hooks using absolute Windows paths are broken after the upgrade
  • Affects any Windows/MINGW user with custom hooks
  • In my case: 27 hooks across PreToolUse, PostToolUse, SessionStart, SessionEnd, and Stop lifecycle events were all broken simultaneously

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗