ReferenceError: Bun is not defined on Windows (Node.js)

Resolved 💬 3 comments Opened Jan 31, 2026 by Tortuga928 Closed Feb 4, 2026

Environment

  • Claude Code version: 2.1.27
  • Node.js version: v24.13.0
  • Platform: Windows 11 (MINGW64/Git Bash)
  • Installation method: npm global (npm install -g @anthropic-ai/claude-code)

Description

Claude Code repeatedly throws ReferenceError: Bun is not defined errors during operation. The error appears to occur during auto tool search functionality. Sessions continue after the error but may become unstable or crash.

Error from debug logs (~/.claude/debug/*.txt)

[ERROR] ReferenceError: ReferenceError: Bun is not defined
    at Z34 (file:///C:/Users/MSTor/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1602:27809)
    at f34 (file:///C:/Users/MSTor/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1614:83)
    at C5q (file:///C:/Users/MSTor/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:4787:6330)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async file:///C:/Users/MSTor/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:4787:3611
    at async Z$A (file:///C:/Users/MSTor/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:1027:2007)
    at async pM1 (file:///C:/Users/MSTor/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:4787:3581)
    at async mN (file:///C:/Users/MSTor/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3186:5201)

Steps to reproduce

  1. Install Claude Code via npm on Windows: npm install -g @anthropic-ai/claude-code
  2. Run Claude Code in a project directory
  3. Use tools (Glob, Bash, etc.) during a session
  4. Check debug logs in ~/.claude/debug/ - error appears multiple times

Expected behavior

No Bun-related errors when running under Node.js on Windows.

Additional context

The error appears to be non-fatal initially but may contribute to session instability. The code appears to have a code path that expects the Bun runtime to be available, but the npm-installed version runs under Node.js.

View original on GitHub ↗

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