[BUG] Windows: preview_start always fails with "spawn cmd.exe ENOENT" regardless of runtimeExecutable
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:
- Apply the #17312 shell:true (or shell:'cmd.exe') fix to the preview spawn path.
- Resolve relative cwd against the project root (or document it must be absolute).
- Error message should distinguish "binary not found" vs "cwd does not exist".
Error Messages/Logs
Steps to Reproduce
- Project where Claude Code's working dir != project root (e.g. project at C:\dl\app, session cwd elsewhere)
- .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"
- Call preview_start
- 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
Claude Code version: 2.1.131 OS: Windows 11 Pro 26200
Platform
Anthropic API
Operating System
Windows
Terminal/Shell
Other
Additional Information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗