You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
打开npm直接报错Api invoke error Error invoking remote method 'apiInvoke': Error: /bin/sh: npm: command not found #427
针对 npm 加速失败的问题(尤其是通过 nvm 在用户级安装 Node.js 的用户),可以在软件“NPM加速”界面中,将“npm命令名”修改为source ~/.bashrc && npm(若使用 Zsh,则改为 source ~/.zshrc && npm)
有人建议直接填写 npm 的绝对路径,但测试发现会因找不到 node 而报错,因此推荐上述加载配置文件的方式。其原理是 dev-sidecar 执行 npm 时未自动加载用户的 shell 配置文件(如 ~/.bashrc),导致 nvm 设置的 PATH 未生效。对于非 nvm 用户,此问题可能不相关,但也可以尝试此方法。
For users experiencing npm acceleration failures (especially those who installed Node.js via nvm in user space), you can fix it by going to the "NPM Acceleration" settings in the software and changing the "npm command" field to:source ~/.bashrc && npm“(If you use Zsh, use source ~/.zshrc && npm instead.)
Some suggest using the absolute path to npm, but tests show that this leads to node: No such file or directory errors. So the above approach (loading the shell config file) is recommended. The reason is that dev-sidecar does not automatically load your shell configuration files (like ~/.bashrc) when executing npm, so the PATH set by nvm is not available. For non‑nvm users, this may not be the cause of the error, but you can still give it a try.
Activity
wangliang181230 commentedon Jan 2, 2025
看下环境变量有没有配置吧。
Ericlyclyclyc commentedon Jan 4, 2025
me too...
什么鬼:
Api invoke error Error invoking remote method 'apiInvoke': Error: 'npm' �����ڲ����ⲿ���Ҳ���ǿ����еij��� ���������ļ���Ericlyclyclyc commentedon Jan 4, 2025
cmd打开npm正常啊
lanhao945 commentedon Jan 6, 2025
遇到了类似的问题。
在ubuntu 22.04 下, node 和npm 均以安装好(通过nvm安装),且终端中node -v 和 npm -v 均能正确输出版本信息。
终端和dev-sidecar 以相同用户启动。
当dev-sidecar 选中npm 代理时,输出异常“Api invoke error Error invoking remote method 'apiInvoke': Error: /bin/bash: 行 1: npm: 未找到命令”
wangliang181230 commentedon Jan 6, 2025
估计是权限问题,你们把ds的权限提高一下试试。
ammondu commentedon Jan 6, 2025
wangliang181230 commentedon Jan 6, 2025
你们尝试下把npm的完整路径配置到 ds 的 npm命令里试一下?
wangliang181230 commentedon Jan 6, 2025
如:

ammondu commentedon Jan 6, 2025
我mac下确实没有这个 /bin/sh: npm: command not found
ammondu commentedon Jan 6, 2025
我在我mac中brew install npm 问题解决。你们可以继续讨论。
lanhao945 commentedon Jan 6, 2025
通过查找npm 路径得到:
home/username/.nvm/versions/node/v23.5.0/bin/npm然后按照要求,在devsidecar中配置npm 路径,重启后,尝试开启npm 代理:
Error invoking remote method 'apiInvoke': Error: /usr/bin/env: "node": 没有那个文件或目录从表现来看,不像是权限,更像是,devsidecar中将node 的路径(或者npm路径)写得相对固定?
lanhao945 commentedon Jan 6, 2025
这是devsidecar core.log 中关于node 的部分日志:
lanhao945 commentedon Jan 6, 2025
ubuntu中通过apt install 应该能解决这个问题。但是这里主要是用到了nvm,是希望通过nvm 来控制node 的版本。估计是引入了nvm 导致了逻辑不兼容。
9 remaining items
Ericlyclyclyc commentedon Jan 23, 2025
然后,发现关闭代理(点圆型按钮)在点开(也是点圆形按钮)就会自动打开了
sdqdyzz commentedon Apr 14, 2026
cute-omega commentedon Aug 18, 2026
如果确实遇到该问题,请在npm设置里写入你要调整的npm的完整路径
RepublicGlory commentedon Aug 22, 2026
RepublicGlory commentedon Aug 22, 2026
希望作者直接将nvm相应配置中直接加入 source ~/.bashrc 等相应指令,有助于新人直接使用,若还未添加,可以看前一个回复,有解决方法。
lrx012 commentedon Oct 18, 2026
feat(feedback): 一键打包日志并打开 issue(#42)