[BUG] Windows: preview_start always fails with "spawn cmd.exe ENOENT" regardless of runtimeExecutable

Resolved 💬 1 comment Opened Jun 14, 2026 by GurkanB-Bot Closed Jun 14, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

On Windows 11, preview_start fails with spawn C:\WINDOWS\System32\cmd.exe ENOENT
for every launch.json config. Changing runtimeExecutable from "npm" to "node" does
NOT help — the error stays identical and names cmd.exe, which means the preview tool
wraps the command in cmd.exe unconditionally and that wrapper spawn is what fails
(not the target executable). This is the cmd.exe variant of #44414, distinct from the
"spawn npm ENOENT" variant in #27459.

Root cause: npm/npx are .cmd shims; Node's child_process.spawn needs shell:true to run
them. The LSP path got this fix in #17312 and the MCP path was flagged in #58510, but
the preview/dev-server spawn path still lacks it.

Secondary bug: relative cwd in launch.json resolves against the editor's working
directory, not the project root, so "cwd": "frontend" silently points to a nonexistent
path (Node reports this as "spawn <exe> ENOENT", masking the real cause).

What Should Happen?

preview_start launches the dev server. Specifically:

  1. Apply the #17312 shell:true (or shell:'cmd.exe') fix to the preview spawn path.
  2. Resolve relative cwd against the project root (or document it must be absolute).
  3. Error message should distinguish "binary not found" vs "cwd does not exist".

Error Messages/Logs

OS: Windows 11 Pro 26200
cmd.exe exists (Test-Path → True), %ComSpec% = C:\WINDOWS\system32\cmd.exe (correct)
Related: #44414, #27459, #58510, #17312

Steps to Reproduce

  1. Project where Claude Code's working dir != project root (e.g. project at C:\dl\app, session cwd elsewhere)
  2. .claude/launch.json with any of:

a) "runtimeExecutable": "npm", "runtimeArgs": ["run","dev"]
b) "runtimeExecutable": "node", "runtimeArgs": ["node_modules/next/dist/bin/next","dev"]
c) cwd as relative "frontend" OR absolute "C:\\dl\\app\\frontend"

  1. Call preview_start
  2. Every variant fails: Failed to start preview server: spawn C:\WINDOWS\System32\cmd.exe ENOENT

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.131

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗