npm install 返回 syscall spawn git 错误

Cha*_*itu 12 git node.js npm node-modules angular

我尝试运行 npm install 并在下面遇到这些问题

我尝试使用强制命令清除缓存,安装 git 和更新节点,但没有任何效果

这是错误

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\UserName\AppData\Roaming\npm-cache\_logs\2019-11-01T11_56_42_862Z-debug.log
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?

yaz*_*han 26

确保您的设备上安装了 GIT 并且可以全局访问。尝试输入git --versionCMD。如果返回该命令无法识别并且已经安装了 GIT,则需要将其添加到 PATH 环境变量中,并确保使用新的 CMD 会话尝试该命令

  • 我相信现在需要 git --version 。我的系统是使用 Visual Studio 的 iMac。 (2认同)

Dem*_*xel 14

如果您使用的是 docker 映像,alpine 版本不包含git. 要么切换到非 alpine 版本(例如,node:16而不是node:16-alpine),要么以其他方式安装 git(更多信息请参见此处)。