【问题标题】:npm ERR! enoent undefined when running npm installnpm 错误!运行 npm install 时未定义 enoent
【发布时间】:2019-11-21 01:58:14
【问题描述】:

我曾经在我的 Windows 7 电脑上运行我的 Angular 项目。我安装了 Windows 2016 和所有需要的工具。由于我没有备份我的 node_modules 文件夹,因此我需要为我的 Angular 项目安装必要的依赖项才能运行。当我运行命令npm install 时,出现以下错误:

C:\Angular_Prj>npm install
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:
npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-07-11T09_48_53_918Z-debug.log

我在谷歌上寻找解决方案添加了 Windows 路径变量%APPDATA%\npm,但它不起作用。奇怪的是我没有在我的项目中使用 FileSaver.js。我怎样才能让npm install 工作?

【问题讨论】:

  • 你是否安装了 git 并在终端中可用?
  • 显然它在终端中不可用。我必须添加路径 C:\Program Files\Git 才能使其工作。太感谢了。如果您写的是答案而不是评论,我可以将其标记为已接受的答案。
  • 很高兴听到它已解决。我已经添加了答案。

标签: node.js angular npm-install


【解决方案1】:

我加了

RUN apk update
RUN apk add git 

进入我的 dockerfile,它现在可以工作了。

【讨论】:

  • 这为我解决了。
【解决方案2】:

此问题是由于未安装 Git 或在终端中不可用引起的。赠品是错误日志中的这一行:

npm ERR! enoent spawn git ENOENT

基本上这意味着命令git无法执行,因为它没有找到。

在再次运行此命令之前,请确保已安装 git 并将其添加到您的 PATH。

【讨论】:

  • 这也是我的解决方案,但我忘记重新启动我的 IDE (WebStorm),所以它不知道新安装的 git 命令行工具。因此,如果安装 git 后问题仍然存在,请记住重新启动您的 IDE/终端。
猜你喜欢
  • 2020-02-20
  • 1970-01-01
  • 1970-01-01
  • 2021-08-31
  • 1970-01-01
  • 1970-01-01
  • 2022-01-17
  • 2018-11-22
相关资源
最近更新 更多