运行 npm i (exit code 1) 尝试安装项目依赖项时发生错误

an error occurred while running npm i (exit code 1) while trying to install project dependencies

我只是将一个 Ionic 项目克隆到我的电脑上,因为使用了 .gitignore 指令中没有安装 node_modules ...所以当我在 CLI 中输入 ionic serve 时,出现了这个错误

?看起来像一个新的结帐!找不到 ./node_modules 目录。您要安装项目依赖项吗?是的 安装依赖项可能需要几分钟时间!

npm i × Running command - failed! [ERROR] An error occurred while running npm i (exit code 1):

    npm ERR! code 1
    npm ERR! Command failed: C:\Program Files\Git\cmd\git.EXE submodule update -q --init --recursive
    npm ERR! C:\Program Files\Git\mingw64/libexec/git-core\git-submodule: line 7: basename: command not found
    npm ERR! C:\Program Files\Git\mingw64/libexec/git-core\git-submodule: line 7: sed: command not found
    npm ERR! C:\Program Files\Git\mingw64/libexec/git-core\git-submodule: line 19: .: git-sh-setup: file not found
    npm ERR!

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\malre\AppData\Roaming\npm-cache\_logs18-06-28T14_57_56_909Z-debug.log

我该怎么做才能解决这个问题?

谢谢

您使用的是哪个文件系统?您碰巧在 windows 上使用 bash 吗?你 运行 npm install -g ionic cordova 了吗?如果那是你失败的地方,请 运行 作为管理员使用的任何终端或 npm i 作为 root

这应该可以解决您的问题。