尝试使用 NPM 进行安装时,出现错误:“子模块”不是 git 命令
适用于 Windows 的 Git bash(版本:2.20.1.windows.1)
$ npm install
Unhandled rejection Error: Command failed: C:\PROGRAM FILES\GIT\mingw64\bin\git.EXE submodule update -q --init --recursive
git: 'submodule' is not a git command. See 'git --help'.
at ChildProcess.exithandler (child_process.js:294:12)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
npm ERR! cb() never called!
npm ERR! This is an error with npm itself.
我是 GIT 初学者,我需要你的帮助来找到解决方案?!谢谢
最佳答案
使用 simplified PATH 重试和一个可移植的 Git(如 PortableGit-2.20.1-64-bit.7z.exe
),可以在任何您想要的地方解压。
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
set PATH=c:\path\to\npm;%PATH%
然后使用 npm install
命令检查该 CMD session (您已在其中设置所述简化路径)中问题是否仍然存在。
关于node.js - 子模块不是 git 命令(在 Windows 的 GIT 上使用 NPM),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54658370/