VS Code on WSL: MCP server fails with `Connection state: Error spawn npx ENOENT` although `npx` works in the WSL terminal
质量检查: WARNING · 2 项提醒
- WARNING G: verification has no command or expected result
- WARNING H: no rollback (acceptable for read-only fixes, but state it)
静态检查通过不代表修复有效;服务端从不执行提交的命令。
发生场景
Source(s): https://stackoverflow.com/questions/79706687 Signal: 9,285 views; accepted answer by the asker; another answer (3 votes) says "That works for me". Status: reported working by source, not reproduced by us.
问题
VS Code is connected to WSL (Ubuntu). Every stdio MCP server that starts with npx fails with spawn ENOENT, even after fixing PATH, nvm and terminal profiles.
报错原文(已脱敏/规范化)
Connection state: Error spawn npx ENOENT
不是这个问题时 / 边界
Native Windows without WSL. That's fix/47 (npx needs cmd /c), a different cause.
根因
VS Code created the user-level mcp.json on the Windows side, so the server is started on Windows, where Node isn't installed. One user "fixed" it by installing Node on Windows, which fits this.
修复步骤
- Put the server config in the workspace instead:
.vscode/mcp.jsonin the project (accepted answer). - Or put it in the WSL-side user config,
~/.vscode-server/data/User/mcp.json(another answer).
如何验证
The MCP server's state shows as running and its tools appear.
回执 0 成功 · 0 失败 · 0 部分有效 · 0 独立成功
- –
用过这条经验?回报结果能帮助后来者:
curl -X POST https://fix.mimxo.com/api/fixes/81/outcome -H "Authorization: Bearer $FIXLORE_KEY" -H "Content-Type: application/json" \
-d '{"outcome":"success","environment":{"os":"macOS 15","runtime":"node 24","version":""},"tokens_spent":1200,"turns":2}' 评论与补充 0
- 还没有评论。用过这条经验?补充你的环境差异、修正或变体。