npm安装时显示git未找到错误

22
我最近在 package JSON 中添加了一些依赖项并尝试安装 npm,但它显示与未找到 git 相关的错误:
``` npm ERR! path git npm ERR! code ENOENT npm ERR! errno ENOENT npm ERR! syscall spawn git 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: ``` Image

你是否已经安装了Git?错误来自于“undefined ls-remote”,应该是“git ls-remote”。 - Shashank Vivek
安装Git是必要的吗? - Harikrishnan C U
是的,你需要安装git。 - Shashank Vivek
https://stackoverflow.com/search?q=%5Bgit%5D+npm+ERR%21+enoent+undefined+ls-remote - phd
请确保“以管理员身份运行命令提示符”。这对我有效。 - alextc
2个回答

30

为了让它正常工作,您需要在计算机上安装 git

undefined ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git

应该已经完成了

git ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git

与git路径相关的错误。 查看此ls-remote命令


我尝试了相同的> git ls-remote -h -t ssh://git@github.com/eligrey/FileSaver.js.git 命令。重新运行yarn时出现以下错误... - Omprakash Sharma
警告:模式["file-saver@eligrey/FileSaver.js#1.3.8"]试图在相同的目标"C:\Users\[xyz]\AppData\Local\Yarn\Cache\v1
pm-file-saver-2.0.5-cea522bc41bfadc364"中解压缩,就像模式["file-saver@github:eligrey/FileSaver.js"]一样。这可能导致不确定性行为,跳过。 错误:命令执行失败。 退出代码:128 命令:git 参数:ls-remote --tags --heads ssh://git@github.com/eligrey/FileSaver.js.git 目录:C:\Users[xyz]\git[repo] 输出: git@github.com: Permission denied (publickey)。 fatal: Could not read from remote repository.
- Omprakash Sharma

11
在我的情况中,我已经安装了Git,但只能从Git Bash访问(我在安装时选择了下面的第一个选项)。我重新安装了第二个选项,问题得到解决。
请查看以下链接以获取更多信息:

输入图像描述


4
我也一样。别忘了重新启动,否则在命令提示符中就无法使用git命令。 - Pauloco
重新启动!!!哈哈哈哈哈 - jon

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接