{"data":{"id":"46396487-85f7-4b03-b5ca-8e0b3aef2398","slug":"fix-mcp-server-npx-connection-error-enoent-32000-with-nvm-fnm-volta-mise-in-claude-desktop-cursor-and-vs-code-1holb3","title":"Fix MCP Server npx Connection Error (ENOENT/-32000) with NVM, fnm, Volta, mise in Claude Desktop, Cursor, and VS Code","summary":"GUI applications like Claude Desktop, Cursor, and VS Code spawn MCP server processes using child_process.spawn() with shell:false, which means Node Version Manager (NVM, fnm, Volta, mise, n, proto, nvm-windows, nodenv) shell functions and PATH modifications are not inherited. This causes 'spawn npx ENOENT', 'env: node: No such file or directory', and MCP server connection failures with error code -32000. The root cause is that Electron-based apps do not source shell profiles (.zshrc, .bashrc) before spawning child processes. Additionally, Claude Desktop enumerates all installed NVM Node versions and resolves the alphabetically-first (often oldest pre-v18) version, which fails with modern MCP servers requiring Node >=18 — this explains why some MCP servers mysteriously work while others fail. Five proven workarounds exist: absolute paths, shell wrapper scripts, bash -c wrappers, env PATH injection, and version-manager-native exec commands. This issue has 91 comments, 182 reactions, and affects virtually every Node developer using a version manager with MCP.","symptoms":["Error: spawn npx ENOENT — MCP server process cannot be spawned because npx is not found on PATH","env: node: No such file or directory — npx resolves but cannot find the Node binary","MCP server connection error -32000 in Claude Desktop logs","MCP servers appear in configuration but tools never load in the client (silent failure — server logs say 'connected' but hammer icon absent)","Server started and connected successfully appears in logs but tools are unavailable (Claude Desktop MCP logs show connection then immediate silent disconnect)","npm ERR! Invalid dependency type requested: alias — old Node version (v10, v14) picked up by GUI app","command not found: node when checking MCP debug diagnostic config","Claude Desktop resolves oldest NVM Node version instead of default or latest — npx works for servers tolerant of old Node but fails for those requiring >=18","Some MCP servers work perfectly with npx while others fail with ENOENT from the same config (selective failure pattern)"],"error_signatures":["spawn npx ENOENT","Error: spawn npx ENOENT at Process.ChildProcess._handle.onexit","env: node: No such file or directory","MCP error -32000: Connection closed","npm ERR! Invalid dependency type requested: alias","Cannot find module '/@playwright/mcp@latest'","Error: Cannot find module","EPIPE error (broken pipe after spawn)","ENOENT errno: -2, syscall: 'spawn node'"],"possible_causes":["GUI apps use child_process.spawn() with shell: false, so shell environment (NVM PATH, shell functions like nvm use, nvm exec) is not loaded — this is a design limitation of the MCP TypeScript SDK's StdioClientTransport","Claude Desktop enumerates all installed NVM versions and picks the alphabetically-first (oldest), which may be pre-v18 and thus incompatible with modern MCP servers requiring Node >=18 for npm alias dependencies and ES module features","npx internally spawns additional shell commands (sh, node) that also need correct PATH resolution; providing full path to npx without PATH env still fails because npx can't find node to execute the package","Electron-bundled apps do not inherit the system PATH from shell profiles (.zshrc, .bashrc, .bash_profile) — they only see launchd/systemd environment which has no NVM entries","NVM relies on shell functions (nvm use, nvm exec) which are unavailable in non-shell spawn contexts — nvm.sh must be explicitly sourced","Version managers that use shims (fnm, Volta, proto, mise) may have shims that resolve correctly in terminal but not in GUI-spawned processes because shim directories are not on the GUI app's PATH","Windows nvm-windows uses .cmd shims which behave differently from Unix symlinks in spawn contexts — spawn on Windows requires .cmd extension or shell:true to execute .cmd files","Selective failure pattern: when multiple NVM Node versions are installed, some MCP servers with loose engine requirements (e.g., node >=10) work fine on the old resolved version, while servers requiring >=18 fail — this creates confusion because 'some npx servers work' suggests npx is available when the real problem is wrong Node version"],"tags":[],"environment":{"os":["macOS","Linux","Windows"],"clients":["Claude Desktop","Claude Code","Cursor","VS Code","Cline"],"mcp_sdk":"@modelcontextprotocol/sdk","version_managers":["nvm","fnm","Volta","mise","n","proto","nvm-windows","nodenv"]},"affected_versions":["Claude Desktop 0.7.0 — 0.8.0+ (all versions using Electron spawn)","MCP TypeScript SDK all versions (spawn shell:false is by design)","Node < 18 when old versions present in NVM alongside newer ones","nvm-windows all versions (cmd shim incompatibility with spawn)"],"status":"published","content_confidence":0.95,"verification_status":"unverified","created_by_type":"agent_admin","language":"en","translation_group_id":"6b6eb3f2-2932-436d-901a-a1c666aa6923","duplicate_of":null,"canonical_url":null,"source_url":null,"extra":{},"created_at":"2026-06-11T07:58:02.927Z","updated_at":"2026-06-11T08:05:30.531Z","tools":[],"solutions":[{"id":"29283a96-2518-4c2f-8d97-b89b933d5f93","issue_id":"46396487-85f7-4b03-b5ca-8e0b3aef2398","title":"Version manager exec commands — Use fnm exec, mise exec, nvm exec, nvs exec (Version-manager-native, most idiomatic)","summary":"Use your version manager's built-in exec command to run npx in the correct Node environment. This is the most idiomatic approach for each version manager and avoids PATH manipulation entirely. Each version manager has its own exec syntax.","steps":["Identify your version manager: fnm, mise, nvm, nvs, or Volta","Use the version manager's exec command as the MCP command in claude_desktop_config.json","Pass the version specifier and npx invocation as args","Ensure the version manager binary is on a standard PATH that GUI apps can access (/usr/local/bin or similar)","Restart Claude Desktop"],"commands":["# fnm\nfnm exec --using=default npx -y @modelcontextprotocol/server-github","# mise\nmise exec node@latest -- npx -y @upstash/context7-mcp","# nvs\nnvs exec 22.14.0 npx -y @playwright/mcp@latest","# nvm (if nvm-exec is available)\nnvm exec default npx -y @modelcontextprotocol/server-filesystem /tmp","# Volta (find the binary path — different approach)\nvolta which node"],"config_examples":["{\n  \"mcpServers\": {\n    \"github\": {\n      \"command\": \"fnm\",\n      \"args\": [\"exec\", \"--using=default\", \"npx\", \"-y\", \"@modelcontextprotocol/server-github\"],\n      \"env\": {\"GITHUB_PERSONAL_ACCESS_TOKEN\": \"<TOKEN>\"}\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"context7\": {\n      \"command\": \"mise\",\n      \"args\": [\"exec\", \"node@latest\", \"--\", \"npx\", \"-y\", \"@upstash/context7-mcp\"]\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"playwright\": {\n      \"command\": \"nvs\",\n      \"args\": [\"exec\", \"22.14.0\", \"npx\", \"-y\", \"@playwright/mcp@latest\"]\n    }\n  }\n}"],"explanation":null,"risks":["fnm exec requires fnm binary on GUI-accessible PATH (may not be if fnm installed via Homebrew in /opt/homebrew/bin)","nvm exec may not be available in all nvm installations (depends on nvm version)","mise exec uses '--' separator between mise args and the command to execute — omitting it silently breaks"],"risk_level":"low","verification_steps":["Run the exact exec command in terminal: e.g., 'fnm exec --using=default npx -y @modelcontextprotocol/server-filesystem /tmp' → expect: 'Secure MCP Filesystem Server running on stdio'","Verify version manager binary location: 'which fnm' → expect: /usr/local/bin/fnm or similar (NOT just in shell function)","If binary not on standard PATH → install with: 'curl -fsSL https://fnm.vercel.app/install | bash -s -- --install-dir /usr/local/bin'","Restart Claude Desktop → hammer icon (🔨) should appear; check logs for 'Server started and connected successfully'"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:12.641Z","updated_at":"2026-06-11T07:58:12.641Z"},{"id":"9d93fc6e-6fb6-4e29-abe4-28e77d4259a8","issue_id":"46396487-85f7-4b03-b5ca-8e0b3aef2398","title":"env PATH injection — Set PATH in MCP config env block (Cleanest minimal config change)","summary":"Add an 'env' block to each MCP server config with PATH set to include the correct Node binary directory plus /bin (required for npx internal shell commands). This is the most minimal config change — no scripts, no global installs, no shell wrappers. Just one env block per server.","steps":["Find your Node binary path: which node","Add an 'env' object to each MCP server config in claude_desktop_config.json","Set PATH to include your Node bin directory AND /bin (/bin is REQUIRED because npx internally spawns sh)","For proto version manager: use the versioned path (/Users/.../.proto/tools/node/X.Y.Z/bin), NOT the globals shim path","Restart Claude Desktop"],"commands":["which node","# Check current PATH for reference\necho $PATH","# Verify Node version is >= 18\nnode -v","# For proto: find correct versioned bin path\nls ~/.proto/tools/node/"],"config_examples":["{\n  \"mcpServers\": {\n    \"filesystem\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-filesystem\", \"/Users/YOUR_USERNAME/Desktop\"],\n      \"env\": {\n        \"PATH\": \"/Users/YOUR_USERNAME/.nvm/versions/node/v20.10.0/bin:/bin\"\n      }\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"playwright\": {\n      \"command\": \"npx\",\n      \"args\": [\"@playwright/mcp@latest\"],\n      \"env\": {\n        \"PATH\": \"/Users/YOUR_USERNAME/.nodenv/versions/20/bin:/bin\"\n      }\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"memory\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-memory\"],\n      \"env\": {\n        \"PATH\": \"/Users/YOUR_USERNAME/.proto/tools/node/23.9.0/bin:/bin\"\n      }\n    }\n  }\n}"],"explanation":null,"risks":["Must update PATH when Node version changes (add to maintenance notes)","Must manually discover the correct Node bin directory for your version manager","For proto: the globals/bin shim path fails with ENOENT/EPIPE — must use the versioned tools/node/X.Y.Z/bin path","Omitting /bin from PATH causes silent 'env: node: No such file or directory' — npx can't find sh to execute node"],"risk_level":"low","verification_steps":["Test PATH in isolation: 'PATH=/Users/.../v20.10.0/bin:/bin npx -y @modelcontextprotocol/server-filesystem /tmp' → expect: 'Secure MCP Filesystem Server running on stdio' (NOT 'env: node: No such file' or 'spawn npx ENOENT')","Restart Claude Desktop → check MCP log for 'Using MCP server command: npx' followed by successful connection","Hammer icon (🔨) should appear in chat input bar","If hammer icon absent despite 'connected' in logs → Node version may be too old (<18); verify with 'node -v' on the path in PATH"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:11.914Z","updated_at":"2026-06-11T07:58:11.914Z"},{"id":"669a847b-d49d-4839-84ca-f80d30be6b14","issue_id":"46396487-85f7-4b03-b5ca-8e0b3aef2398","title":"bash -c wrapper — Use a shell to load NVM environment inline (Works for ALL version managers)","summary":"Set 'bash' as the command and pass the full npx invocation as a shell command string via -c. This forces a shell context where .nvm/nvm.sh can be sourced, making nvm use and npx available. This is the most universal approach — works across NVM, fnm, Volta, mise, n, and nodenv without per-manager customization.","steps":["Set command to 'bash' in MCP config","In args, pass '-c' followed by the shell command that sources nvm and runs npx","For NVM: source $HOME/.nvm/nvm.sh && nvm use --silent <version> && npx -y <package>","For fnm users: 'eval \"$(fnm env --use-default)\" && npx -y <package>'","For simpler setups: just 'export PATH=/path/to/node/bin:$PATH && npx -y <package>'","Restart Claude Desktop"],"commands":["# NVM version\nsource $HOME/.nvm/nvm.sh && nvm use --silent 23 && npx -y @wonderwhy-er/desktop-commander","# fnm version\neval \"$(fnm env --use-default)\" && npx -y @modelcontextprotocol/server-filesystem /tmp","# Simple PATH version (any version manager)\nexport PATH=/Users/user/.nvm/versions/node/v22.14.0/bin:$PATH && npx -y @modelcontextprotocol/server-filesystem /Users/user/Desktop"],"config_examples":["{\n  \"mcpServers\": {\n    \"desktop-commander\": {\n      \"command\": \"bash\",\n      \"args\": [\n        \"-c\",\n        \"source $HOME/.nvm/nvm.sh && nvm use --silent 23 && npx -y @wonderwhy-er/desktop-commander\"\n      ]\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"filesystem\": {\n      \"command\": \"bash\",\n      \"args\": [\n        \"-c\",\n        \"export PATH=/Users/YOUR_USERNAME/.nvm/versions/node/v22.14.0/bin:$PATH && npx -y @modelcontextprotocol/server-filesystem /Users/YOUR_USERNAME/Desktop\"\n      ]\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"github\": {\n      \"command\": \"bash\",\n      \"args\": [\n        \"-c\",\n        \"eval \\\"$(fnm env --use-default)\\\" && npx -y @modelcontextprotocol/server-github\"\n      ],\n      \"env\": {\"GITHUB_PERSONAL_ACCESS_TOKEN\": \"<TOKEN>\"}\n    }\n  }\n}"],"explanation":null,"risks":["Slightly more verbose config than other solutions","Shell sourcing adds ~100-300ms startup latency (negligible for MCP)","Nested quoting can be tricky — use single quotes in JSON, double quotes inside bash -c"],"risk_level":"low","verification_steps":["Test the exact bash -c command from terminal: 'bash -c \"source $HOME/.nvm/nvm.sh && nvm use --silent 23 && npx -y @modelcontextprotocol/server-filesystem /tmp\"' → expect: 'Secure MCP Filesystem Server running on stdio'","Verify nvm is sourceable: 'bash -c \"source $HOME/.nvm/nvm.sh && nvm current\"' → expect version string like 'v23.0.0'","Restart Claude Desktop → check MCP logs for 'Server started and connected successfully' with NO ENOENT errors","Hammer icon (🔨) should appear in chat input bar"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:11.192Z","updated_at":"2026-06-11T07:58:11.192Z"},{"id":"83656656-54ff-4613-b959-e983d24c80e6","issue_id":"46396487-85f7-4b03-b5ca-8e0b3aef2398","title":"Shell wrapper script (npx-for-claude) — Version-independent fix (Recommended for NVM users)","summary":"Create a small shell script that auto-detects the latest NVM Node version and executes npx with proper PATH. Place it in /usr/local/bin and use it as the command in MCP config. This is version-independent (auto-detects latest Node) and has 132+ community confirmations. Survives Node version upgrades without config changes.","steps":["Create file /usr/local/bin/npx-for-claude with the auto-detecting script","Make it executable with chmod +x","Update claude_desktop_config.json to use 'npx-for-claude' as command","Test the script from terminal: npx-for-claude -y @modelcontextprotocol/server-filesystem /tmp/test","Restart Claude Desktop"],"commands":["cat > /usr/local/bin/npx-for-claude << 'EOF'\n#!/usr/bin/env bash\nNODE_VERSIONS_DIR=\"$HOME/.nvm/versions/node\"\nif [ -d \"$NODE_VERSIONS_DIR\" ]; then\n  LATEST_NODE_VERSION=$(ls -v \"$NODE_VERSIONS_DIR\" | grep \"^v\" | sort -V | tail -n 1)\n  export PATH=\"$NODE_VERSIONS_DIR/$LATEST_NODE_VERSION/bin:$PATH\"\nfi\nexec npx \"$@\"\nEOF","chmod +x /usr/local/bin/npx-for-claude","# Test from terminal\nnpx-for-claude -y @modelcontextprotocol/server-filesystem /tmp/test"],"config_examples":["{\n  \"mcpServers\": {\n    \"filesystem\": {\n      \"command\": \"npx-for-claude\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-filesystem\", \"/Users/YOUR_USERNAME/Desktop\"]\n    },\n    \"github\": {\n      \"command\": \"npx-for-claude\",\n      \"args\": [\"-y\", \"@modelcontextprotocol/server-github\"],\n      \"env\": {\"GITHUB_PERSONAL_ACCESS_TOKEN\": \"<YOUR_TOKEN>\"}\n    }\n  }\n}"],"explanation":null,"risks":["Script auto-detects latest NVM version; if you need a specific version, replace 'tail -n 1' with explicit version","Requires /usr/local/bin to be writable (sudo may be needed on first creation)","For fnm users: replace the script body with 'eval \"$(fnm env)\" && exec npx \"$@\"'"],"risk_level":"low","verification_steps":["Run from terminal: 'npx-for-claude -y @modelcontextprotocol/server-filesystem /tmp/test' → expect: 'Secure MCP Filesystem Server running on stdio' (server starts and waits for input)","Run 'ls -v $HOME/.nvm/versions/node | grep \"^v\" | sort -V | tail -n 1' → confirm the latest version (e.g., v22.14.0) is what the script will use","Restart Claude Desktop → hammer icon (🔨) should appear in chat input bar","Check MCP log → expect: 'Server started and connected successfully' with NO 'spawn npx ENOENT' errors"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:10.456Z","updated_at":"2026-06-11T07:58:10.456Z"},{"id":"8b4f5e9b-933d-4ba6-826d-2f878184c215","issue_id":"46396487-85f7-4b03-b5ca-8e0b3aef2398","title":"Use absolute path to Node with globally installed MCP package (Easiest, Most Reliable)","summary":"Install the MCP server package globally via npm, then use the absolute path to the Node binary as command and absolute path to the package entry point as args. This completely bypasses PATH resolution and works across all version managers. 132+ community confirmations across the GitHub issue.","steps":["Find your active Node binary path: run 'which node' or 'where node' (Windows)","Install the MCP server globally: npm install -g @modelcontextprotocol/server-filesystem","Find the entry point JS file: look in <npm root -g>/<package>/dist/index.js or /lib/index.js","Configure claude_desktop_config.json with absolute paths for both command and args","Restart Claude Desktop and verify tools appear"],"commands":["which node","npm install -g @modelcontextprotocol/server-filesystem","npm root -g","ls $(npm root -g)/@modelcontextprotocol/server-filesystem/dist/","# Windows (nvm-windows):\n# where node\n# npm install -g <package>\n# npm root -g"],"config_examples":["{\n  \"mcpServers\": {\n    \"filesystem\": {\n      \"command\": \"/Users/YOUR_USERNAME/.nvm/versions/node/v22.11.0/bin/node\",\n      \"args\": [\n        \"/Users/YOUR_USERNAME/.nvm/versions/node/v22.11.0/lib/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js\",\n        \"/Users/YOUR_USERNAME/Desktop\",\n        \"/Users/YOUR_USERNAME/Downloads\"\n      ]\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"puppeteer\": {\n      \"command\": \"/Users/YOUR_USERNAME/.nvm/versions/node/v22.11.0/bin/node\",\n      \"args\": [\n        \"/Users/YOUR_USERNAME/.nvm/versions/node/v22.11.0/lib/node_modules/@modelcontextprotocol/server-puppeteer/dist/index.js\"\n      ]\n    }\n  }\n}","{\n  \"mcpServers\": {\n    \"playwright\": {\n      \"command\": \"C:\\\\nvm4w\\\\nodejs\\\\node.exe\",\n      \"args\": [\n        \"C:\\\\Users\\\\YOUR_USERNAME\\\\AppData\\\\Roaming\\\\npm\\\\node_modules\\\\@playwright\\\\mcp\\\\cli.js\"\n      ]\n    }\n  }\n}"],"explanation":null,"risks":["Must update paths when Node version changes (mitigated by using the npx-for-claude auto-detection script in Solution 2)","Requires global install which may conflict with per-project Node versions — for isolated use, pin to specific version"],"risk_level":"low","verification_steps":["Restart Claude Desktop after config update","Check MCP log at ~/Library/Logs/Claude/mcp-server-filesystem.log → expect: 'Server started and connected successfully' (NOT 'spawn npx ENOENT' or 'Error: spawn node ENOENT')","In Claude Desktop chat input bar → expect hammer icon (🔨) visible indicating MCP tools are loaded and available","Type 'list files on my Desktop' to Claude → expect it to successfully use the filesystem MCP tool and return directory listing","For Claude Code CLI: 'claude mcp list' → expect server status: 'connected'"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:09.721Z","updated_at":"2026-06-11T07:58:09.721Z"},{"id":"d122c580-3c32-4759-886d-76400c7fc818","issue_id":"46396487-85f7-4b03-b5ca-8e0b3aef2398","title":"Diagnostic Pre-Check — Determine which Node version Claude Desktop is using (Run FIRST)","summary":"Before applying any fix, add a temporary debug MCP server to identify exactly which Node binary and version Claude Desktop is resolving. This tells you whether the problem is 'npx not found at all' vs 'wrong/old Node version' — critical for choosing the right fix.","steps":["Add a temporary debug MCP server to claude_desktop_config.json","Restart Claude Desktop","Check logs at ~/Library/Logs/Claude/mcp-server-debug-node.log","The error message reveals which node binary is used: '/usr/local/bin/node' means system Node; an nvm path reveals the version; nothing means no node found","Remove the debug config after diagnosis"],"commands":["# macOS/Linux: find which node Claude Desktop uses\ncat >> ~/Library/Application\\ Support/Claude/claude_desktop_config.json << 'DIAGEOF'\n{\n  \"mcpServers\": {\n    \"debug-node-version\": {\n      \"command\": \"node\",\n      \"args\": [\"-v\"]\n    },\n    \"debug-which-node\": {\n      \"command\": \"which\",\n      \"args\": [\"node\"]\n    }\n  }\n}\nDIAGEOF","# Check logs after restart\nls -lt ~/Library/Logs/Claude/mcp-server-debug-* | head -5","tail -20 ~/Library/Logs/Claude/mcp-server-debug-node-version.log","tail -20 ~/Library/Logs/Claude/mcp-server-debug-which-node.log","# Claude Code CLI: list MCP server statuses\nclaude mcp list 2>/dev/null || echo \"claude mcp list not available\"","# List all NVM versions to check for old ones\nls -v ~/.nvm/versions/node/ | grep \"^v\" 2>/dev/null || echo \"NVM not found\""],"config_examples":[],"explanation":null,"risks":["Diagnostic config will show errors in logs — this is expected and harmless"],"risk_level":"low","verification_steps":["Check debug-node-version log → expect node version output like 'v22.11.0' OR error like 'spawn node ENOENT' (tells you if node is found and which version)","Check debug-which-node log → expect path like '/Users/.../.nvm/versions/node/v22.11.0/bin/node' OR error like 'Unexpected token' (Claude tries to JSON-parse the path — the error message contains the resolved path)","If version is < v18 → the fix is to ensure a >=18 version is used (remove old versions or use a version-pinning solution)","If 'spawn node ENOENT' → npx/node is not on GUI PATH at all (use absolute path or shell wrapper solutions)"],"verified_count":0,"failed_count":0,"source_type":"github","status":"pending_review","language":"en","source_url":null,"extra":{},"created_at":"2026-06-11T07:58:09.002Z","updated_at":"2026-06-11T07:58:09.002Z"}]}}