繁体   English   中英

npm.cmd 在每个命令上都说“系统找不到指定的文件。(操作系统错误2)”

[英]npm.cmd says "The system cannot find the file specified. (os error 2)" on every command

npm.cmd在每个命令上都说“系统找不到指定的文件。(操作系统错误2)”。

例如

>npm -v
Error:
  x The system cannot find the file specified. (os error 2)

8.11.0

该命令看似工作正常,但进程返回码非零,这导致许多 npm 脚本失败。

我已经在两台不同的笔记本电脑(win 10 和 win 11)上安装了几个节点版本(nvm for windows),但它们都有同样的问题。 谷歌搜索这并没有让我感到惊讶。

Another interesting observation is that the bash script called npm (located beside npm.cmd in the installation directory) does not have this problem when running it in git bash. 但是,一些依赖于 npm 的程序和脚本将使用 npm.cmd,无论我如何称呼它们,所以问题仍然存在。 我试过运行npm config set script-shell bash来解决这个问题,但它似乎不起作用。

我在ComSpec环境变量中配置了一个自定义 shell。 删除这个解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM