Error: spawn npx ENOENT
Node.js · updated 2026-11-11
Shown by Claude Desktop, Cursor and other MCP clients (and thrown by the MCP TypeScript SDK's StdioClientTransport) when the "command" in your MCP config can't be found. The SDK starts the server with shell: false and passes only HOME, LOGNAME, PATH, SHELL, TERM and USER plus the "env" from your config, so the PATH is the client app's own. An app opened from the Dock or Start menu doesn't read ~/.zshrc or ~/.bashrc, where nvm, fnm, Volta and Homebrew usually add node and npx.
Error: spawn npx ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:285:19)
at onErrorNT (node:internal/child_process:483:16)
at process.processTicksAndRejections (node:internal/process/task_queues:89:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn npx',
path: 'npx'
}Quick fix
Give the server a PATH that contains node. Run "which node" (or "where node" on Windows) in your terminal and add that folder to PATH in the server's "env". Changing "command" to the full path of npx alone is not enough: npx starts with #!/usr/bin/env node, so it then fails with "env: node: No such file or directory" and the client reports MCP error -32000: Connection closed.
- In a terminal, run which node and which npx to find where they live (for nvm, something like ~/.nvm/versions/node/v22.x/bin).
- Add "env": { "PATH": "<that folder>:/usr/bin:/bin" } to the server entry in the MCP config.
- Or skip npx: install the server package once and set "command" to the full path of node with the server's script as the argument.
- On Windows, npx is npx.cmd, which can't be started without a shell: use "command": "cmd" with "args": ["/c", "npx", ...].
- Restart the client completely (quit it, not just close the window) so it rereads the config.
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "my-mcp-server"],
"env": {
"PATH": "/Users/you/.nvm/versions/node/v22.11.0/bin:/usr/bin:/bin"
}
}
}
}Paste this into Claude Code, Cursor or Codex in the project that throws it. The agent reads this guide in plain text and applies the fix that matches your stack.
Read https://runheed.com/errors/spawn-npx-enoent-mcp.md and fix this error in this project.Why it happens
node comes from nvm, fnm, Volta or Homebrew
Those tools add themselves to PATH in your shell profile. A desktop app started outside a terminal never runs that profile, so its PATH has only the system folders.
The command is a script, not a binary
npx and npm are scripts that run node through /usr/bin/env, so they also need node on the PATH, not just a full path to themselves.
Windows .cmd wrappers
On Windows, npx is npx.cmd. Clients start servers without a shell, and Node can't start .cmd or .bat files without one.
The package or binary isn't installed
A "command" that names a globally installed CLI (uvx, docker, python3) fails the same way when it isn't installed or isn't on the app's PATH.
Other fixes
- Read the client's log for the exact command it tried: Claude Desktop writes mcp*.log files to ~/Library/Logs/Claude on macOS; Claude Code shows it with claude --debug=mcp.
- Starting the client from a terminal (open -a, or the CLI) makes it inherit your shell PATH, which is a quick way to confirm the cause.
- For remote MCP servers there is nothing to spawn: connecting by URL avoids PATH problems entirely.
Same error, other wording
- spawn npx ENOENT
- Error: spawn uvx ENOENT
- Error: spawn node ENOENT
- env: node: No such file or directory
Let your coding agent catch the next one
The MCP client could not start your server process, so none of your code ran, and Runheed doesn't record it. What it does record is the exceptions your running server code throws (route handlers, server rendering, API errors and background jobs) with the stack trace and the breadcrumbs before them, and serves those errors to Claude Code, Cursor or any MCP client.
Setup for Node.js and Express or Vercel Functions, then have your agent fix and resolve it.
Building an MCP server? Track the errors your tools raise, in TypeScript or Python, so a failing tool shows up with its line instead of only in your users' client logs.
Related errors
- McpError: MCP error -32000: Connection closed
- Error: ENOENT: no such file or directory, open '/app/config.json'
- McpError: MCP error -32001: Request timed out
More in MCP servers and clients
- MCP error -32602: Input validation error: Invalid arguments for tool get_orderNode.js
- Bad Request: No valid session ID providedNode.js
- Not Acceptable: Client must accept both application/json and text/event-streamNode.js
- ModuleNotFoundError: No module named 'mcp.server.fastmcp'Python
- Error executing tool get_orderPython
- Bad Request: Unsupported protocol version: 2026-07-28Node.js
References: MCP TypeScript SDK: stdio client transport (spawn, inherited env), MCP docs: debugging (environment variables, absolute paths), MCP docs: connect to local servers (Claude Desktop logs, Windows ENOENT), Node.js docs: spawning .bat and .cmd files on Windows
Spotted a mistake? Email hello@greatwork.company. About Runheed.