Skip to content

Connect MCP Servers error"spawn npx enoent" #1948

Closed

Description

@Archer456

What happened?

Connect MCP Servers error"spawn npx enoent"

Steps to reproduce

  1. npx -y @smithery/cli@latest install @executeautomation/playwright-mcp-server --client cline
    2.Image

Relevant API REQUEST output

Operating System

windows11 23H2

Cline Version

3.4.8

Additional context

No response

Activity

  1. alemarro commented on Feb 25, 2025

    @alemarro

    this

  2. TheComplianceAide commented on Feb 25, 2025

    @TheComplianceAide

    I've had this occur in the past 3-4 days, on multiple Windows development systems.

  3. bobbyiscool123 commented on Feb 25, 2025

    @bobbyiscool123

    i HATE THISSSSSSSSSSSSSSSSSSSS
    IS THERE ANY SOLUTIONS I HAVE THIS ISSUE AND TRYING TO FIX FOR HOURS
    I DIDNT EVEN HAD EXPERIENCED MCP SERVERS YET
    AHHHHHHHHHHHHHHHHHHHHHHHHHH

  4. ByteCoO commented on Feb 26, 2025

    @ByteCoO

    Image

    Environment configuration problem, this is the only way to configure。

    {
    "mcpServers": {
    "fetch": {
    "command": "uvx",
    "args": [
    "mcp-server-fetch"
    ],
    "env": {
    "PYTHONIOENCODING": "utf-8"
    },
    "disabled": false,
    "autoApprove": []
    },
    "puppeteer": {
    "command": "C:\Program Files\nodejs\node.exe",
    "args": [
    "D:\Program Files\nodejs\node_modules\npm\node_modules\@modelcontextprotocol\server-puppeteer\dist\index.js"
    ],
    "disabled": false,
    "autoApprove": []
    },
    "playwright": {
    "command": "C:\Program Files\nodejs\node.exe",
    "args": [
    "D:\Program Files\nodejs\node_modules\npm\node_modules\@executeautomation\playwright-mcp-server\dist\index.js"
    ],
    "disabled": false,
    "autoApprove": [
    "playwright_click"
    ]
    }
    }
    }

  5. Archer456 commented on Feb 26, 2025

    @Archer456
    Author

    Image

    Environment configuration problem, this is the only way to configure。

    { "mcpServers": { "fetch": { "command": "uvx", "args": [ "mcp-server-fetch" ], "env": { "PYTHONIOENCODING": "utf-8" }, "disabled": false, "autoApprove": [] }, "puppeteer": { "command": "C:\Program Files\nodejs\node.exe", "args": "D:\Program Files\nodejs\node_modules\npm\node_modules[@modelcontextprotocol\server-puppeteer\dist\index.js" ], "disabled": false, "autoApprove": [] }, "playwright": { "command": "C:\Program Files\nodejs\node.exe", "args": "D:\Program Files\nodejs\node_modules\npm\node_modules[@executeautomation\playwright-mcp-server\dist\index.js" ], "disabled": false, "autoApprove": [ "playwright_click" ] } } }

    Thank you so much, referring to your configuration, I thought about my way, and finally got it right.

    Image

    { "mcpServers": { "@executeautomation-playwright-mcp-server": { "command": "D:\\nodejs\\node.exe", "args": [ "D:\\nodejs\\node-global\\node_modules\\@executeautomation\\playwright-mcp-server\\dist\\index.js", "-y", "@smithery/cli@latest", "run", "@executeautomation/playwright-mcp-server", "--config", "\"{}\"" ] } } }

    I will use Chinese below. Sorry, English is not my native language.

    好吧,这东西折腾了我一天时间,没错。一天时间。我下边将为大家总结错误,但我并不肯定这些错误都是在不同电脑和操作系统下一定会复现的。

    一、 我最开始是用 fnm 方式安装的nodejs。
    我本机是用powershell7.5+oh-my-posh提示的。
    参考 https://nodejs.org/zh-cn/download/ 和 https://github.com/Schniz/fnm
    其实,我是成功在pwsh7.5 上安装和部署好了node 22.14的。并没有什么问题。
    也在pwsh7.5 用 https://smithery.ai/server/@executeautomation/playwright-mcp-server 提到的安装命令 npx -y @smithery/cli@latest install @executeautomation/playwright-mcp-server --client cline 安装成功了。

    安装完后的配置文件是这样的。
    { "mcpServers": { "@executeautomation-playwright-mcp-server": { "command": "npx", "args": [ "-y", "@smithery/cli@latest", "run", "@executeautomation/playwright-mcp-server", "--config", "\"{}\"" ] } } }
    打开vscode 的cline插件,打开mcp servers 也看到了装上了playwright-mcp-server但就是连接报错,我反复搜索和问了很多AI这个关键词spawn npx ENOENT spawn npx ENOENT 都告诉我说是npx或者说node安装的问题。

    那么,我不得不怀疑是fnm + nodejs 的部署问题,可一切node -v 、npm -v 、npx -v 在pwsh7.5 在vscode里的pwsh7.5 都是正常的。

    直到我看了你的回复里的配置,发现你应该不是用的fnm部署的nodejs。
    所以,我完全确认卸载掉nodejs 和 fnm ,重新用node-v22.14.0-x64.msi 安装包的方式,重新部署了nodejs。
    为了方便管理nodejs,我做了如下的事情:
    我的安装路径 D:\nodejs
    D:\nodejs下 新建三个文件夹 node-cache 、 node-global 、 \node-global\node_modules
    环境变量:
    Image

    ` Archer@Jade  15:24:26 
    ~ ❯ node -v
    v22.14.0
     Archer@Jade  took  518ms 15:24:30 
    ~ ❯ npm -v
    10.9.2
     Archer@Jade  took  450ms 15:24:35 
    ~ ❯ npm config set prefix "D:\nodejs\node-global"
     Archer@Jade  took  369ms 15:27:54 
    ~ ❯ npm config set cache "D:\nodejs\node-cache"
     Archer@Jade  took  359ms 15:28:02 
    ~ ❯ npm config get prefix
    D:\nodejs\node-global
     Archer@Jade  took  355ms 15:28:09 
    ~ ❯ npm config get cache
    D:\nodejs\node-cache

    ~ ❯ npm install -g [email protected]

     Archer@Jade  took  333ms 15:41:19 
    ~ ❯ npx -y @smithery/cli@latest install @executeautomation/playwright-mcp-server --client cline
    ✔ Successfully resolved @executeautomation/playwright-mcp-server
    @executeautomation/playwright-mcp-server successfully installed for cline`

    可惜 这个 npx -y @smithery/cli@latest install @executeautomation/playwright-mcp-server --client cline 安装命令安装后,vscode里的cline mcp servers 还是一样的错误 spawn npx ENOENT spawn npx ENOENT 并且一些命令也都是有问题的。比如
    npx @smithery/cli installed --client cline 和 npx @smithery/cli uninstall playwright-mcp-server --client cline 明明安装成功了,installed 却不列出来。。。 我只能怀疑npx 这种方式有问题。

    最终看了 https://github.com/executeautomation/mcp-playwright 用这个命令安装
    npm install -g @executeautomation/playwright-mcp-server

    因为我设置了node-cache 和node-global 所以,我最终在自己的安装相关路径下找到了类似你的配置里的,最终改了配置playwright mcp server就连接成功了。

    我太难了。。。。开源作者们,咱们不都是苹果系统开发环境吧? 能对windows系统友好些么?

    初步怀疑smithery.ai 提供的npx -y 命令是有问题的,建议不要通过这种方式安装,而是npm install -g 的方式。
    或者说npx -y的这种方式生成的mcp server默认配置在win系统环境下是无法直接运行成功的,可能对苹果系统很友好,一路默认
    安装开箱即用了? 哎。。。

    fnm 安装的nodejs 我个人感觉并没有什么问题,只是默认不改任何配置的话,它的安装路径默认的太复杂,不方便以后找安装的node_modules,所以我改为了 .msi的安装方式,指定node-global来管理node_modules安装路径。

  6. Archer456 commented on Feb 26, 2025

    @Archer456
    Author

    好吧,我不得不说,目前windows11系统,vscode +cline插件,通过https://smithery.ai/ 的

    Image
    类似 npx -y @smithery/cli@latest install @smithery-ai/fetch --client cline 的命令在pwsh7.5 下的安装方式,是无法做到安装后即用的。
    我安装完 playwright-mcp-server 又尝试了下 https://github.com/smithery-ai/mcp-fetch
    还是用 https://smithery.ai/ 的 npx -y @smithery/cli@latest install @smithery-ai/fetch --client cline 安装完后,还是spawn npx ENOENT spawn npx ENOENT ,没办法,我只能照老虎画猫,找到配置文件的规律。
    对比着playwright-mcp-server的配置和 github上https://github.com/kazuph/mcp-fetch提供的零星的关键词信息。

    哦。。。差点遗漏了,实际上还得改安装命令,还是照样改成 npm install -g @kazuph/mcp-fetch 这种安装的才有用,npx -v 纯属在那摆设的。。

    "@executeautomation-playwright-mcp-server": {
    "command": "D:\nodejs\node.exe",
    "args": [
    "D:\nodejs\node-global\node_modules\@executeautomation\playwright-mcp-server\dist\index.js",
    "-y",
    "@smithery/cli@latest",
    "run",
    "@executeautomation/playwright-mcp-server",
    "--config",
    ""{}""
    ]

    来改 mcp-fetch的配置:
    "@kazuph-mcp-fetch": {
    "command": "D:\nodejs\node.exe",
    "args": [
    "D:\nodejs\node-global\node_modules\@kazuph\mcp-fetch\dist\index.js",
    "-y",
    "@smithery/cli@latest",
    "run",
    "@kazuph/mcp-fetch",
    "--config",
    ""{}""
    ]

    最终也成功连接到这个mcp-fetch server了。。。。

    Image

    我去非苹果系统的安装mcp servers 太难了。。。。。 希望能适配windows系统下的vscode + cline插件更友好的安装方式,做到一键部署即可使用,否则非技术专业的用起来太难了。

  7. theCyberTech commented on Feb 26, 2025

    @theCyberTech

    Image
    same issue here Cline on Windsurf, MacOS

  8. Archer456 commented on Feb 27, 2025

    @Archer456
    Author

    其实怀疑,不是配置文件的问题,而是windows下的vscode,不设置node绝对路径的话,vscode没法正确找到本机安装的node 或npx 。
    .msi 安装的nodejs,按我以上的步骤,以及mcp servers配置文件里写node绝对路径,是可以正常连接mcp servers的。

    我现在,还是想正常弄好windows11 vscode cline插件,可以让mcp servers配置文件里的npx 直接能正常找到本机的node。
    所以,我又重新winget 装回了fnm,但是尝试了一圈,发现这个fnm是不是在vscode没提供什么配置项,还是我没找到如何正确在vscode理配置好fnm?
    我也用了fnm use 等命令来指定node版本。
    Image
    可见,pwsh7和vscode里cline的pwsh ,which npx 的路径都是fnm 每次虚拟出来的。。。
    那vscode 里不特别指定的 话,vscode应该找不到本机已经安装好的npx的。

    如果,可以正确配置好vscode下的fnm 或者说fnm管理的node版本路径问题,就可以让vscode根据mcp servers的配置去正确唤起npx了。
    但我现在,没找到怎么在vscode下配置fnm nodejs.
    有谁熟悉,vscode下如何配置正确fnm node的?

  9. Archer456 commented on Feb 27, 2025

    @Archer456
    Author

    Hello, everyone. I have sorted out the steps for VSCode+Cline plug-in to correctly connect to mcp servers in the win environment. I hope it can help AI product enthusiasts all over the world to take the first step in using AI and mcp servers.
    "This is just a small step, but it is a big step for ordinary humans to use AI"
    Sorry, I was naughty.
    Sorry again, this is a Chinese content, you may need to use a translator to read it.
    https://medium.com/@sayharer/vscode-cline%E6%8F%92%E4%BB%B6%E9%83%A8%E7%BD%B2mcp-server-win%E7%B3%BB%E7%BB%9F-b079c3d254dc
    If you find it helpful, please move your hands, like, follow, and collect it.

  10. cdxiaodong commented on Feb 28, 2025

    @cdxiaodong

    Hello, everyone. I have sorted out the steps for VSCode+Cline plug-in to correctly connect to mcp servers in the win environment. I hope it can help AI product enthusiasts all over the world to take the first step in using AI and mcp servers. "This is just a small step, but it is a big step for ordinary humans to use AI" Sorry, I was naughty. Sorry again, this is a Chinese content, you may need to use a translator to read it. https://medium.com/@sayharer/vscode-cline%E6%8F%92%E4%BB%B6%E9%83%A8%E7%BD%B2mcp-server-win%E7%B3%BB%E7%BB%9F-b079c3d254dc If you find it helpful, please move your hands, like, follow, and collect it.

    感谢大佬哦

  11. cdxiaodong commented on Feb 28, 2025

    @cdxiaodong

    windows最简单的方法

    1. 安装nodejs.msi
    2. npm config set prefix "D:\nodejs\npm-global"
    3. npm install -g “package”
    4. cline_mcp_setting.json -> comman :"node.exe", args:""D:\nodejs\npm-global\node_modules\'package'\dist\index.js"
  12. Archer456 commented on Mar 3, 2025

    @Archer456
    Author

    NND, windows系统果然不是开发编程人员的亲儿子.
    我用老婆的mbp 随便一顿安装,直接命令行npx 安装,配置自动生成,vscode保存下该配置.就自动安装mcp servers成功了.全程毫无波澜,丝滑...

    NND, Windows system is not the favorite son of developers and programmers.
    I used my wife's mbp to install it casually, directly installed it with the command line npx, the configuration was automatically generated, and vscode saved the configuration. Then the mcp servers were automatically installed successfully. The whole process was smooth and smooth...

    Image
  13. nanobiolog commented on Mar 8, 2025

    @nanobiolog

    Add this C:\Users<YourUsername>\AppData\Roaming\npm to your SYS Variables PATH

  14. 23 remaining items

  15. Eskiii commented on Mar 28, 2025

    @Eskiii

    我已经确认以下事实:

    1. Windows上软件子进程由cmd提供支持,意味着对powershell和powershell 7的单独环境变量配置将无法使用

    2. fnm几乎无法使用,因为fnm对cmd的支持较差,不自行配置的话,cmd中无法加载fnm的环境变量。fnm使用动态环境变量来支持npm切换。

    3. 问题存在两个

      • claude执行npx需要npx在cmd的路径中,也就是系统环境变量正确就行,单独安装node和pnpm都能做到 ✅
      • cline执行npx即使npx在cmd的路径中也不行,也就是claude能用的,cline不能用❌
    Image 以下是cline的写法✅,在cline中需要强制使用cmd启动npx才能运行,默认终端可能连cmd都不是,是无法获取系统环境变量的终端 Image Conclusion: Use `cmd /c` instead of only `npx` in Cline { "mcpServers": { "playwright": { "command": "cmd", "args": [ "/c", "npx", "-y", "@executeautomation/playwright-mcp-server" ] } } } instead of { "mcpServers": { "playwright": { "command": "npx", "args": [ "-y", "@executeautomation/playwright-mcp-server" ] } } } I think this is a issue of Cline.

    感谢老哥,够细心,够深度。 我今早开车也无意油管给我推了个介绍mcp的 也提到了windows里要 `> "command": "cmd",

      "args": [
        "/c",
        "npx",`
    

    我试验了下 是可以的。
    Image
    那这究竟是 我的默认终端 powershell7.5 和 fnm pnpm 适配的锅? 还是cline 的锅?

    Track the issue back to the upstream Anthropic TS SDK. modelcontextprotocol/typescript-sdk#101

    本质上是 claude 开源的mcp ts sdk的锅,它对Windows的兼容有问题,但是他们自己的桌面端用其他库修复了这个问题,sdk的没修

    cline的话也没处理,直接用的sdk所以会出问题

    powershell 7我看了一下和powershell 5运行方式基本上是差不多的,也就是没啥问题,我装着用了比5好用太多(

    fnm和mcp的适配是有问题的,这个就很难办,建议换一个,不用它

    wc感谢大佬!!!终于连上了,windows真的折腾好久了

  16. arjunkmrm commented on Mar 28, 2025

    @arjunkmrm

    Just updated smithery/cli to use latest version of MCP SDK, hope this fixes the spawn npx ENONT error
    arcadeai-labs/smithery-cli#77

  17. Archer456 commented on Mar 28, 2025

    @Archer456
    Author

    Just updated smithery/cli to use latest version of MCP SDK, hope this fixes the spawn npx ENONT error smithery-ai/cli#77

    Image
    Thanks, developer.
    In my pwsh7, I executed npx -y @smithery/cli@latest inspect @executeautomation/playwright-mcp-server --verbose
    Finally, it is the same as in the Mac system, and there is no spawn npx ENONT error

  18. diiiiiiiiiiiiK commented on Apr 7, 2025

    @diiiiiiiiiiiiK

    我安装filesystem过程中以上的方法仍然不能用,把配置改成这样,大家可以试试
    "github.com/modelcontextprotocol/servers/tree/main/src/filesystem": {
    "autoApprove": [],
    "disabled": true,
    "timeout": 60,
    "command": "cmd",
    "args": [
    "/c",
    "npx",
    "-y",
    "@modelcontextprotocol/server-filesystem",
    "d:/AI/MCP"
    ],
    "transportType": "stdio"
    }

  19. behrangsa commented on Apr 12, 2025

    @behrangsa

    Why is this closed? Linux is still broken.

  20. arjunkmrm commented on Apr 12, 2025

    @arjunkmrm

    @behrangsa try using the following command pattern for linux?

    {
      "mcpServers": {
        "playwright-mcp-server": {
          "command": "wsl",
          "args": [
            "npx",
            "-y", ...
          ]
        }
      }
    }
  21. klzns commented on Apr 18, 2025

    @klzns

    The solution is to pass the full path to node in the command field.

    I had this config:

    {
      "mcpServers": {
        "weather": {
          "command": "node",
          "args": [
            "/Users/breno/projects/mcp-server/build/index.js"
          ]
        }
      }
    }

    Open a terminal and run the command:

    which node

    My terminal responded with: /Users/breno/.volta/bin/node

    Use this path in the command field, for example:

    {
      "mcpServers": {
        "weather": {
          "command": "/Users/breno/.volta/bin/node",
          "args": [
            "/Users/breno/projects/mcp-server/build/index.js"
          ]
        }
      }
    }
  22. fangfsz commented on Apr 27, 2025

    @fangfsz

    Image
    Environment configuration problem, this is the only way to configure。
    { "mcpServers": { "fetch": { "command": "uvx", "args": [ "mcp-server-fetch" ], "env": { "PYTHONIOENCODING": "utf-8" }, "disabled": false, "autoApprove": [] }, "puppeteer": { "command": "C:\Program Files\nodejs\node.exe", "args": [ "D:\Program Files\nodejs\node_modules\npm\node_modules@modelcontextprotocol\server-puppeteer\dist\index.js" ], "disabled": false, "autoApprove": [] }, "playwright": { "command": "C:\Program Files\nodejs\node.exe", "args": [ "D:\Program Files\nodejs\node_modules\npm\node_modules@executeautomation\playwright-mcp-server\dist\index.js" ], "disabled": false, "autoApprove": [ "playwright_click" ] } } }

    Thank you so much, referring to your configuration, I thought about my way, and finally got it right.

    Image `{ "mcpServers": { "@executeautomation-playwright-mcp-server": { "command": "D:\\nodejs\\node.exe", "args": [ "D:\\nodejs\\node-global\\node_modules\\@executeautomation\\playwright-mcp-server\\dist\\index.js", "-y", "@smithery/cli@latest", "run", "@executeautomation/playwright-mcp-server", "--config", "\"{}\"" ] } } }`

    I will use Chinese below. Sorry, English is not my native language.

    好吧,这东西折腾了我一天时间,没错。一天时间。我下边将为大家总结错误,但我并不肯定这些错误都是在不同电脑和操作系统下一定会复现的。

    一、 我最开始是用 fnm 方式安装的nodejs。 我本机是用powershell7.5+oh-my-posh提示的。 参考 https://nodejs.org/zh-cn/download/ 和 https://github.com/Schniz/fnm 其实,我是成功在pwsh7.5 上安装和部署好了node 22.14的。并没有什么问题。 也在pwsh7.5 用 https://smithery.ai/server/@executeautomation/playwright-mcp-server 提到的安装命令 npx -y @smithery/cli@latest install @executeautomation/playwright-mcp-server --client cline 安装成功了。

    安装完后的配置文件是这样的。 { "mcpServers": { "@executeautomation-playwright-mcp-server": { "command": "npx", "args": [ "-y", "@smithery/cli@latest", "run", "@executeautomation/playwright-mcp-server", "--config", "\"{}\"" ] } } } 打开vscode 的cline插件,打开mcp servers 也看到了装上了playwright-mcp-server但就是连接报错,我反复搜索和问了很多AI这个关键词spawn npx ENOENT spawn npx ENOENT 都告诉我说是npx或者说node安装的问题。

    那么,我不得不怀疑是fnm + nodejs 的部署问题,可一切node -v 、npm -v 、npx -v 在pwsh7.5 在vscode里的pwsh7.5 都是正常的。

    直到我看了你的回复里的配置,发现你应该不是用的fnm部署的nodejs。 所以,我完全确认卸载掉nodejs 和 fnm ,重新用node-v22.14.0-x64.msi 安装包的方式,重新部署了nodejs。 为了方便管理nodejs,我做了如下的事情: 我的安装路径 D:\nodejs D:\nodejs下 新建三个文件夹 node-cache 、 node-global 、 \node-global\node_modules 环境变量: Image

    ` Archer@Jade  15:24:26  ~ ❯ node -v v22.14.0  Archer@Jade  took  518ms 15:24:30  ~ ❯ npm -v 10.9.2  Archer@Jade  took  450ms 15:24:35  ~ ❯ npm config set prefix "D:\nodejs\node-global"  Archer@Jade  took  369ms 15:27:54  ~ ❯ npm config set cache "D:\nodejs\node-cache"  Archer@Jade  took  359ms 15:28:02  ~ ❯ npm config get prefix D:\nodejs\node-global  Archer@Jade  took  355ms 15:28:09  ~ ❯ npm config get cache D:\nodejs\node-cache

    ~ ❯ npm install -g [email protected]

     Archer@Jade  took  333ms 15:41:19  ~ ❯ npx -y @smithery/cli@latest install @executeautomation/playwright-mcp-server --client cline ✔ Successfully resolved @executeautomation/playwright-mcp-server @executeautomation/playwright-mcp-server successfully installed for cline`

    可惜 这个 npx -y @smithery/cli@latest install @executeautomation/playwright-mcp-server --client cline 安装命令安装后,vscode里的cline mcp servers 还是一样的错误 spawn npx ENOENT spawn npx ENOENT 并且一些命令也都是有问题的。比如 npx @smithery/cli installed --client cline 和 npx @smithery/cli uninstall playwright-mcp-server --client cline 明明安装成功了,installed 却不列出来。。。 我只能怀疑npx 这种方式有问题。

    最终看了 https://github.com/executeautomation/mcp-playwright 用这个命令安装 npm install -g @executeautomation/playwright-mcp-server

    因为我设置了node-cache 和node-global 所以,我最终在自己的安装相关路径下找到了类似你的配置里的,最终改了配置playwright mcp server就连接成功了。

    我太难了。。。。开源作者们,咱们不都是苹果系统开发环境吧? 能对windows系统友好些么?

    初步怀疑smithery.ai 提供的npx -y 命令是有问题的,建议不要通过这种方式安装,而是npm install -g 的方式。 或者说npx -y的这种方式生成的mcp server默认配置在win系统环境下是无法直接运行成功的,可能对苹果系统很友好,一路默认 安装开箱即用了? 哎。。。

    fnm 安装的nodejs 我个人感觉并没有什么问题,只是默认不改任何配置的话,它的安装路径默认的太复杂,不方便以后找安装的node_modules,所以我改为了 .msi的安装方式,指定node-global来管理node_modules安装路径。

    我这里分享下我是如何解决了,我的IDE是Trae国际版,也是用fnm来管理nodejs版本的。在使用Trae国际版安装mcp server时,同样遇到了“ spawn npx ENOENT ”的问题,经过一番折腾,我解决了这个问题,希望对你有所帮助。

    1. Powershell7 和Terminal 都正常识别 fnm, Trae集成的Terminal也可以识别fnm. 问题大概率是MCP Server这边对Terminal里面环境变量或者是配置文件的继承或者识别问题。

    2. 既然fnm可以管理多个版本的node.js,npm和npx都在相应的版本里面,我的想法就是可能会有一个路径指向当前的nodejs目录,通过 fnm env可以找到 $env:FNM_DIR进入这个目录,发现有个别名文件夹,就是这里了。

    Image
    3. 尝试将这个路径 C:\Users[user]\AppData\Roaming\fnm\aliases\default 添加到系统环境变量PATH项下面,然后重启Trae IDE,等一会发现加npx运行的mcp server加载成功了。

    Image

  23. h7ml commented on Apr 30, 2025

    @h7ml

    mac 用户,使用了nrm 和 fnm 当前我的解决方案是

    Image Image
  24. Penghaiku commented on May 5, 2025

    @Penghaiku

    草,浪费了我这么多时间和ai逼逼,原来是这个问题。

    文件系统 MCP 服务器已成功设置。以下是失败配置与成功配置的完整示例及详细解释:

    1. 失败的配置示例(直接使用 npx)

    {
      "mcpServers": {
        "filesystem": {
          "command": "npx",
          "args": [
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "C:/Users/Betterman/Desktop"
          ],
          "disabled": false,
          "autoApprove": []
        }
      }
    }
    • 失败原因详解: 此配置尝试直接运行 npx。问题在于 VS Code 启动 MCP 服务器时所在的子进程环境的 PATH 环境变量可能不完整,导致操作系统无法找到 npx 可执行文件,从而引发底层 spawn npx ENOENT 错误,最终表现为“未连接”错误。这与您在 PowerShell 终端中能成功运行 npx 的情况不同,反映了环境差异。

    2. 最终成功的配置(通过 cmd /c 运行 npx)

    {
      "mcpServers": {
        "filesystem": {
          "command": "cmd",
          "args": [
            "/c",
            "npx",
            "-y",
            "@modelcontextprotocol/server-filesystem",
            "C:/Users/Betterman/Desktop"
          ],
          "disabled": false,
          "autoApprove": []
        }
      }
    }
    • 成功原因详解: 此配置首先启动 Windows 命令提示符 (cmd.exe),它通常位于系统 PATH 中。/c 参数指示 cmd.exe 执行后续的 npx ... 命令。由于 cmd.exe 通常继承了更完整的系统 PATH,它能够成功找到并执行 npx。这种通过 cmd /c 间接执行的方式绕过了 VS Code 子进程环境的 PATH 限制,使得 npx 得以运行,服务器成功启动并连接。

    服务器现已正确配置并可以使用。

  25. canyara commented on May 7, 2025

    @canyara

    使用nvm管理node版本,记得nvm alias default stable。不然shell打开默认版本是8.x,没有npx..

  26. zhibisora commented on May 7, 2025

    @zhibisora

    草,浪费了我这么多时间和ai逼逼,原来是这个问题。

    文件系统 MCP 服务器已成功设置。以下是失败配置与成功配置的完整示例及详细解释:

    1. 失败的配置示例(直接使用 npx)

    {
    "mcpServers": {
    "filesystem": {
    "command": "npx",
    "args": [
    "-y",
    "@modelcontextprotocol/server-filesystem",
    "C:/Users/Betterman/Desktop"
    ],
    "disabled": false,
    "autoApprove": []
    }
    }
    }

    • 失败原因详解: 此配置尝试直接运行 npx。问题在于 VS Code 启动 MCP 服务器时所在的子进程环境的 PATH 环境变量可能不完整,导致操作系统无法找到 npx 可执行文件,从而引发底层 spawn npx ENOENT 错误,最终表现为“未连接”错误。这与您在 PowerShell 终端中能成功运行 npx 的情况不同,反映了环境差异。

    2. 最终成功的配置(通过 cmd /c 运行 npx)

    {
    "mcpServers": {
    "filesystem": {
    "command": "cmd",
    "args": [
    "/c",
    "npx",
    "-y",
    "@modelcontextprotocol/server-filesystem",
    "C:/Users/Betterman/Desktop"
    ],
    "disabled": false,
    "autoApprove": []
    }
    }
    }

    • 成功原因详解: 此配置首先启动 Windows 命令提示符 (cmd.exe),它通常位于系统 PATH 中。/c 参数指示 cmd.exe 执行后续的 npx ... 命令。由于 cmd.exe 通常继承了更完整的系统 PATH,它能够成功找到并执行 npx。这种通过 cmd /c 间接执行的方式绕过了 VS Code 子进程环境的 PATH 限制,使得 npx 得以运行,服务器成功启动并连接。

    服务器现已正确配置并可以使用。

    anthropic的sdk更新之后应该已经不需要这种折中方案了,也许cline没有更新到新版sdk?

  27. 944750720 commented on May 9, 2025

    @944750720

    I use both of wsl2 and macos. Meanwhile, I use fnm for managing nodejs version. I met this problem on both systems. And I think I figure out the reason and solution. No matter you use cline or Cursor.
    Connect MCP Servers error"spawn npx enoent" means mcp client can't correctly find npx command in your system. So if you're using fnm, don't use which npx to set npx path directly. This path is temporarily created by fnm so it'll outdate when restart device.
    The right way is to find to your fnm directory by command which fnm. For example, mine is /Users/CHJ/.local/state/fnm_multishells/32996_1746258653075/bin/npx. Then access to /Users/CHJ/.local/share/fnm/node-version/<select a version you want to use>/installation/bin/, you should be able to see npx file. To my understanding, fnm create temporary folder based on these nodejs versions under /Users/CHJ/.local/share/fnm/.
    Whatever, find the npx file that is constant and permanent. Then use this path alternate the npx in every mcp setting json.
    For example, in wsl2 using context7 mcp server by Cursor:

    {
      "mcpServers": {
        "context7": {
          "command": "wsl",
          "args": [
            "bash",
            "-c",
            "'/Users/CHJ/.local/share/fnm/node-versions/v22.15.0/installation/bin/npx -y @upstash/context7-mcp@latest'"
          ],
          "enabled": true
        }
      }
    }
    

    in macos using context7 mcp server by Cursor:

    {
      "mcpServers": {
            "context7": {
                "command": "/Users/CHJ/.local/share/fnm/node-versions/v22.15.0/installation/bin/npx",
                "args": [
                    "-y",
                    "@upstash/context7-mcp@latest"
                ]
            }
      }
    }
    

    Hope it can help you.

  28. DavidAGInnovation commented on Oct 2, 2025

    @DavidAGInnovation

    I've found a definitive solution for me.

    Click on the Install Server VS Code button from this website: https://www.npmjs.com/package/@playwright/mcp

    Image

    That should fix it!

  29. phoulx commented on Dec 2, 2025

    @phoulx

    On Windows:

    1. Uninstall fnm and related node
    2. Install node using Volta
    3. Reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions