Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Error fixes / spawn npx ENOENT
Fix · MCP

spawn npx ENOENT when starting an MCP server

ENOENT means the command wasn't found, not that the MCP server is broken. Windows: wrap npx with cmd /c, as the official MCP servers README says. macOS and Linux: put the full path from which npx (or which uvx, which node) in command, because an app started from the dock or menu doesn't get your terminal's PATH.

Fix it on Windows

The official modelcontextprotocol/servers README: "On Windows, wrap npx with cmd /c". In claude_desktop_config.json:

{
  "mcpServers": {
    "memory": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@modelcontextprotocol/server-memory"]
    }
  }
}

The same README says to leave uvx entries unchanged: uvx doesn't need the wrapper.

In Claude Code the launch command goes after --, so the same idea is:

claude mcp add --transport stdio memory -- cmd /c npx -y @modelcontextprotocol/server-memory

(Claude Code's docs show the -- form; adding cmd /c applies the README's Windows rule to it.)

Why Windows needs it

On Windows, npx is a script, not a program. Node's docs: ".bat and .cmd files are not executable on their own without a terminal", and their own example runs one through cmd.exe /c. Node's process layer (libuv) only looks for .com and .exe when it searches PATH, so a bare npx isn't found: ENOENT.

If you get spawn EINVAL instead: you pointed command at npx.cmd directly. Since the April 2024 Node security release (CVE-2024-27980), "Node.js will now error with EINVAL if a .bat or .cmd file is passed to child_process.spawn" without a shell. Use cmd /c as above.

Error mentions ${APPDATA}

The MCP docs: if the server's log shows ${APPDATA} inside a path, add the expanded value to the server's env, for example "env": {"APPDATA": "C:\\Users\\you\\AppData\\Roaming"}. The same page notes npx may keep failing if npm isn't installed globally: npm install -g npm.

Fix it on macOS and Linux

  1. In a terminal, find the real path: which npx (or which uvx, which node).
  2. Put that full path in command, for example "command": "/opt/homebrew/bin/npx".
  3. Restart the app completely.

Why: tools installed with nvm, asdf, Homebrew or uv (which puts uvx in ~/.local/bin) are added to PATH by your shell profile. The MCP docs: servers launched over stdio "inherit only a limited subset of environment variables automatically". VS Code's FAQ describes the same thing for apps started from the macOS dock: "you don't have access to those environment settings".

Alternatively, set PATH for that one server in its env block. Node looks the command up "using the options.env.PATH environment variable if env is in the options object".

Check it the official way

  1. Run the exact command yourself in a terminal, with the same arguments. If it fails there, fix the install first (the Filesystem server, for example, needs Node.js 24 or later).
  2. Read the logs. Claude Desktop: ~/Library/Logs/Claude (macOS), %APPDATA%\Claude\logs (Windows), ~/.config/Claude/logs (Linux). mcp.log has connection failures; mcp-server-NAME.log has that server's stderr. Claude Code: /mcp shows each server's status.
  3. Restart fully after editing the config, then try a request that needs the server's tools.

Variants of the same error

You seeMeans
spawn npx ENOENT / spawn uvx ENOENTThat command isn't on the PATH the app sees
spawn node ENOENTSame, for node (common with nvm). VS Code shows it as Connection state: Error spawn node ENOENT
spawn claude ENOENTA client running claude mcp serve can't find claude: use its full path (which claude)
spawn EINVALWindows, npx.cmd passed directly: use cmd /c

Running Claude Code, Codex or Cursor on real repos, or shipping an AI agent? A Quick Review ($149 / ₹13,900, 1 working day) checks one repo, config or setup for leaked keys, risky agent permissions and MCP servers. Request a Quick Review

FAQ

What does spawn npx ENOENT mean?

The app tried to start your MCP server with npx and couldn't find the npx command. The server itself may be fine. It is a PATH or Windows script problem.

How do I fix spawn npx ENOENT on Windows?

Set command to cmd and put /c, npx and the package in args, as the official MCP servers README says: "command": "cmd", "args": ["/c", "npx", "-y", "<package>"].

Why does npx work in my terminal but not in Claude Desktop?

Your terminal loads your shell profile, which adds nvm, Homebrew or uv to PATH. An app started from the dock or Start menu doesn't. Use the full path from which npx, or set PATH in the server's env.

Why do I get spawn EINVAL instead of ENOENT?

Since Node's April 2024 security release, passing a .cmd file such as npx.cmd to spawn without a shell is refused with EINVAL. Use cmd /c npx instead.

Related errors

Sources

Read 2 Dec 2026. These tools change often: if a step no longer matches, the linked page wins.

Related free tools