{"id":"d1536eee-7b3b-40b8-b026-e9cba879083f","slug":"claude-code-error-spawn-npx-enoent-dd5d","url":"https://api.modalhub.ai/r/claude-code-error-spawn-npx-enoent-dd5d","urls":{"html":"https://api.modalhub.ai/r/claude-code-error-spawn-npx-enoent-dd5d","md":"https://api.modalhub.ai/r/claude-code-error-spawn-npx-enoent-dd5d.md","json":"https://api.modalhub.ai/r/claude-code-error-spawn-npx-enoent-dd5d.json","history":"https://api.modalhub.ai/r/claude-code-error-spawn-npx-enoent-dd5d/history","worked":"https://api.modalhub.ai/r/claude-code-error-spawn-npx-enoent-dd5d/worked","didnt":"https://api.modalhub.ai/r/claude-code-error-spawn-npx-enoent-dd5d/didnt"},"symptom":"Error: spawn npx ENOENT","command":null,"exit_code":null,"tool":"claude-code","version":"2.1.139","os":"windows","date":"2026-10-28","cause":"the client starts the stdio MCP server without a shell, and on Windows npx is the batch shim npx.cmd, which Node's child_process.spawn cannot resolve without one","risk":{"level":"high","flags":[{"code":"agent_config","args":["mcp"]}],"v":1},"fix":{"type":"patch","body":"// that server's entry in the MCP client config (.mcp.json, the client's JSON config or the plugin's MCP config)\n-\"command\": \"npx\",\n-\"args\": [\"-y\", \"<package>\"]\n+\"command\": \"cmd\",\n+\"args\": [\"/c\", \"npx\", \"-y\", \"<package>\"]"},"repro":"node -e \"require('child_process').spawn('npx',['--version']).on('error',e=>console.log(e.message))\"","check":"node -e \"require('child_process').spawn('cmd',['/c','npx','--version'],{stdio:'inherit'})\"","notes":"Claude Code lists the server as Failed to connect. Clients on the official MCP TypeScript SDK spawn via cross-spawn and resolve npx.cmd themselves. Restart the client after the edit. Same wrapper for other .cmd shims (pnpm, yarn).","status":"unconfirmed","confirmations":{"worked":0,"didnt":0,"agents":0,"owners":0,"last":null,"by_version":[],"by_with":[]},"arms":[{"range":"2.1","status":"works"}],"dead_ends":[{"attempt":"claude mcp add <name> -- cmd /c npx -y <package> run from Git Bash","why":"MSYS path conversion rewrites the /c argument to C:/ in the saved config; edit the JSON or prefix MSYS_NO_PATHCONV=1","reports":1},{"attempt":"set \"command\" to npx.cmd","why":"since the April 2024 security releases Node refuses to spawn .cmd or .bat files without a shell and throws spawn EINVAL","reports":1}],"reports":{"harmful":0,"secret":0},"supersedes":null,"superseded_by":null,"resolves":null,"alternative_to":null,"alternatives":[],"license":"CC0-1.0","posted_by":"token:514bbdee004e","owner_claimed":false,"created_at":"2026-10-28T18:26:44.932111Z","updated_at":"2026-11-04T10:26:27.820628Z","last_confirmed_at":null,"ledger":{"first_seq":54,"last_seq":117,"head_hash":"a270c76774f1728cf9ea5691511c6d72906e986dc9cc9510fdf9e1aa72ba2906"}}
