Back to Blog
TroubleshootingOct 28, 20269 min read

Fix "spawn npx ENOENT" in MCP Servers: Claude Desktop, Cursor & Windows

NT

Nikhil Tiwari

MCP Playground

πŸ“– TL;DR

  • spawn npx ENOENT means the MCP client could not find the npx program. Your server code never ran.
  • On a Mac, apps opened from the Dock get a short PATH (/usr/bin:/bin:/usr/sbin:/sbin) that leaves out Homebrew, nvm, Volta and uv. Fix it with an absolute path and a PATH in the server's env.
  • On Windows, npx is really npx.cmd, which Node can't start directly. Use "command": "cmd" with "/c", "npx" at the start of args.
  • Everywhere, put only the program in command. "npx -y some-server" in one string fails with the same error.
  • Running the server from your terminal hides the bug, because the terminal has the full PATH. Test it in an app opened the same way as your MCP client.

Table of Contents

What "spawn npx ENOENT" means

A local MCP server that uses the stdio transport is a program the client starts for you. Claude Desktop, Cursor and other clients read the command and args from their config file and start the program with Node's child_process.spawn.

ENOENT is the operating system's "no such file or directory" error. spawn npx ENOENT means Node looked for a program called npx in every folder on the client's PATH and did not find it. Nothing from your server ran, so there is nothing wrong with its code yet.

Most of the time npx is installed and works in your terminal. The client simply has a different PATH from the one your terminal has.

Find your exact error

Error Where Cause Fix
spawn npx ENOENT macOS Dock apps don't see Homebrew, nvm or Volta Absolute path plus PATH
env: node: No such file or directory macOS, Linux You gave the full path to npx, but node is still not on PATH Add PATH to env
spawn npx ENOENT Windows npx is a .cmd script, not an .exe cmd /c npx
spawn EINVAL Windows You used npx.cmd directly; newer Node refuses to start .cmd files without a shell cmd /c npx
spawn npx -y @scope/server ENOENT Any Arguments are inside command Move them to args
spawn uvx ENOENT, spawn docker ENOENT Mostly macOS Same PATH problem, different program Absolute path

Where to find the error

Claude Desktop only shows "Server disconnected" or a red dot in the window. The full error is in its log files:

  • macOS: ~/Library/Logs/Claude/. Each server has its own mcp-server-NAME.log, and mcp.log covers all of them.
  • Windows: %APPDATA%\Claude\logs\

On a Mac you can watch it live while you restart the client:

tail -n 50 -f ~/Library/Logs/Claude/mcp*.log

In Cursor, open the Output panel and choose the MCP logs from the dropdown. The config files themselves are listed in MCP Config File Location: Claude Desktop, Cursor & Claude Code.

Fix on macOS: absolute path plus PATH

An app you open from the Dock, Finder or Spotlight is started by launchd, not by your shell. It gets the system's default PATH:

/usr/bin:/bin:/usr/sbin:/sbin

None of the usual places Node ends up are on that list: Homebrew (/opt/homebrew/bin on Apple Silicon, /usr/local/bin on Intel), nvm (~/.nvm/versions/node/…/bin), Volta (~/.volta/bin), fnm or asdf. Your terminal finds npx because .zshrc or .zprofile adds those folders. The Dock app never reads those files.

Step 1: Find where npx and node are

In Terminal:

which npx
which node

You'll see something like /opt/homebrew/bin/npx or /Users/you/.nvm/versions/node/v22.11.0/bin/npx. Both are usually in the same folder.

Step 2: Use the absolute path, and pass PATH

Put the full path in command, and give the server a PATH that includes the same folder:

{
  "mcpServers": {
    "filesystem": {
      "command": "/Users/you/.nvm/versions/node/v22.11.0/bin/npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects"],
      "env": {
        "PATH": "/Users/you/.nvm/versions/node/v22.11.0/bin:/usr/local/bin:/usr/bin:/bin"
      }
    }
  }
}

The env part matters. npx is a small script whose first line is #!/usr/bin/env node, so it looks up node on PATH as soon as it starts. With only the absolute path, the error changes to env: node: No such file or directory. Many people stop at that point and decide the fix didn't work.

nvm users: the version number is in the path, so the config breaks the next time you install a newer Node and remove the old one. Either update the path when you change versions, or point the config at a Node that keeps the same path, such as Homebrew's /opt/homebrew/bin/npx or Volta's ~/.volta/bin/npx.

Step 3: Quit and reopen the client

Closing the window is not enough. Quit Claude Desktop with Cmd+Q (or Cursor from its menu) and open it again, so it reads the config file again.

Fix on Windows: cmd /c npx

On Windows, Node installs npx as npx.cmd, a batch script. child_process.spawn without a shell only starts real executables, so it can't find a program called npx. That gives ENOENT.

Writing npx.cmd doesn't help on current Node either. Since the April 2024 security releases (CVE-2024-27980), Node refuses to start .cmd and .bat files without a shell and throws spawn EINVAL instead.

Let cmd.exe start it for you:

{
  "mcpServers": {
    "filesystem": {
      "command": "cmd",
      "args": ["/c", "npx", "-y", "@modelcontextprotocol/server-filesystem", "C:\\Users\\you\\projects"]
    }
  }
}

Two details trip people up:

  • Backslashes are doubled in JSON: C:\\Users\\you, not C:\Users\you. A single backslash makes the whole file invalid, and then every server disappears.
  • If Node was installed after the client was opened, quit the client from the system tray (not just the window) so it picks up the new PATH. If where npx in a new PowerShell window finds nothing, Node isn't on PATH at all; reinstall it with "Add to PATH" ticked.

Fix everywhere: one program in "command"

This config looks reasonable, but it fails on every system:

"command": "npx -y @modelcontextprotocol/server-filesystem /Users/you/projects"

The client doesn't split command on spaces. It looks for one program whose name is that whole string, and the log shows the whole string in the error: spawn npx -y @modelcontextprotocol/server-filesystem /Users/you/projects ENOENT. Put the program alone in command and every word after it in args, one array item each:

"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/projects"]

Same error for uvx, node, python and docker

Any program can hit this, not only npx. Common ones on a Mac and where they live:

Program Usual location
uvx / uv (official installer)~/.local/bin/uvx
uvx (Homebrew)/opt/homebrew/bin/uvx
docker (Docker Desktop)/usr/local/bin/docker
python3 in a virtualenv/path/to/project/.venv/bin/python

Always check with which uvx (or where uvx on Windows) rather than trusting this table. For a Python server in a virtualenv, point command straight at the venv's python. That also makes sure the server gets the packages you installed.

Check the fix before you restart the client

The usual way to test is to run the server, or the MCP Inspector, from your terminal. For this bug that test is misleading: the terminal has your full PATH, so it works there even while the client still fails.

A better check is to start the server the way the client does: from an app you opened from the Dock or Start menu, with exactly the command, args and env from your config.

MCP Playground Desktop does this and shows you what happened:

  • Import your Claude Desktop, Cursor, VS Code, Windsurf or Claude Code config. Each server comes in with its command, arguments and environment variables.
  • Connect and see the result: the tool list if it started, or the spawn error and the server's own stderr output if it didn't.
  • On a Mac it loads your login shell's PATH at startup, so a server that works in your terminal also works here. If it connects in MCP Playground but not in Claude Desktop, you know the server is fine and the client's PATH is the problem.
  • On Windows it starts npx, uvx and other .cmd scripts correctly, so you can test the server before you get the cmd /c wrapper right.

Once it connects, call a tool or two to be sure the server works, not just starts. How to test local MCP servers walks through that. If the server starts but then disconnects, see MCP Server Not Working? Fix Error -32000, Timeouts, and Connection Failures.

Frequently Asked Questions

Why does npx work in my terminal but not in Claude Desktop?+
Your terminal reads .zshrc or .zprofile, which add Homebrew, nvm or Volta to PATH. Claude Desktop opened from the Dock is started by launchd with only /usr/bin:/bin:/usr/sbin:/sbin, so it can't find npx. Use the absolute path to npx and add a PATH entry in the server's env.
I used the full path to npx and now get "env: node: No such file or directory". Why?+
npx is a script that starts with #!/usr/bin/env node, so it still needs node on PATH. Add "env": { "PATH": "folder-containing-node:/usr/bin:/bin" } to the server's config entry.
How do I fix spawn npx ENOENT on Windows?+
Set "command" to "cmd" and start args with "/c", "npx", followed by the package and its arguments. npx on Windows is npx.cmd, which Node can't start without a shell. Using "npx.cmd" directly fails with spawn EINVAL on current Node versions.
Where are Claude Desktop's MCP logs?+
On macOS in ~/Library/Logs/Claude/ (mcp.log and one mcp-server-NAME.log per server). On Windows in %APPDATA%\Claude\logs\.
Does spawn uvx ENOENT have the same fix?+
Yes. Find it with which uvx (usually ~/.local/bin/uvx or /opt/homebrew/bin/uvx), put that absolute path in "command", and quit and reopen the client.

Conclusion

spawn npx ENOENT is almost never a bug in your server. On a Mac, give the client the absolute path and a PATH. On Windows, wrap the command in cmd /c. Everywhere, keep arguments out of command.

Then check the server outside the client, started the same way the client starts it. Get MCP Playground Desktop for Mac and Windows β†’

NT

Written by Nikhil Tiwari

15+ years in product development. AI enthusiast building developer tools that make complex technologies accessible to everyone.

Build, compare & ship MCP agents

Connect any MCP server, run evals on it, compare 80+ models side-by-side, deploy hosted servers, and save reusable agents you can export as an API β€” all in your browser.

Try for Free β†’
Fix "spawn npx ENOENT" in MCP Servers: Claude Desktop, Cursor & Windows