错误! 运行 npm install 时未定义

npm ERR! enoent undefined when running npm install

我曾经 运行 我的 Angular 项目在我的 windows 7 件中。我安装了 Windows 2016 和所有必要的工具。我需要为我的 angular 项目安装必要的依赖项到 运行,因为我没有备份我的 node_modules 文件夹。当我 运行 命令 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\_logs19-07-11T09_48_53_918Z-debug.log

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

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

npm ERR! enoent spawn git ENOENT

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

确保 git 已安装并添加到您的 PATH 中,然后再次 运行 此命令。

我加了

RUN apk update
RUN apk add git 

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