Node.js ';子模块';似乎是git命令,但我们无法执行它

Node.js ';子模块';似乎是git命令,但我们无法执行它,node.js,git,visual-studio,npm,npm-install,Node.js,Git,Visual Studio,Npm,Npm Install,我已经克隆了一个git存储库,它是一个Angular 7&.NET核心应用程序,项目中的一切都很好,但是当我尝试恢复npm包时,我得到了以下错误 \Microsoft\TeamFoundation\Team Explorer\Git\cmd\Git.EXE子模块 update-q--init--recursive 致命:“submodule”似乎是git命令,但我们不是 能够执行它。也许git子模块坏了? 在ChildProcess.exithandler(child_process.js:29

我已经克隆了一个git存储库,它是一个Angular 7&.NET核心应用程序,项目中的一切都很好,但是当我尝试恢复npm包时,我得到了以下错误

\Microsoft\TeamFoundation\Team Explorer\Git\cmd\Git.EXE子模块 update-q--init--recursive 致命:“submodule”似乎是git命令,但我们不是 能够执行它。也许git子模块坏了? 在ChildProcess.exithandler(child_process.js:291:12) 在ChildProcess.emit(events.js:182:13) 在maybeClose(内部/子进程js:961:16) at Process.ChildProcess.\u handle.onexit(internal/child\u Process.js:248:5) npm错误!我从没打过电话

#Package.json

{
 "name": "name",
 "version": "6.1.1",
 "license": "......",
 "scripts": {
   "ng": "ng",
   "start": "ng serve --open",
   "start-hmr": "ng serve --configuration hmr -sm=false",
   "start-hmr-sourcemaps": "ng serve --hmr -e=hmr",
   "build": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev",
   "build-stats": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --dev --stats-json",
   "build-prod": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod",
   "build-prod-stats": "node --max_old_space_size=6144 ./node_modules/@angular/cli/bin/ng build --prod --stats-json",
   "test": "ng test",
   "lint": "ng lint",
   "e2e": "ng e2e",
   "bundle-report": "webpack-bundle-analyzer dist/stats.json"
},
"private": true,
"dependencies": {
  "@agm/core": "1.0.0-beta.3",
  "@angular/animations": "6.0.5",
  "@angular/cdk": "6.2.1",
  "@angular/common": "6.0.5",
  "@angular/compiler": "6.0.5",
  "@angular/core": "6.0.5" 
},
"devDependencies": {
  "@angular-devkit/build-angular": "0.6.8",
  "@angular/cli": "6.0.8",
  "@angular/compiler-cli": "6.0.5",
  "@angular/language-service": "6.0.5",
  "@angularclass/hmr": "2.1.3",  
  "typescript": "2.7.2",
  "webpack-bundle-analyzer": "2.13.1"
  }
}
我安装的
节点版本
10.7.0
npm版本
6.4.1


我在GitHub上发现了一些类似的问题,他们在npm生命周期中添加了一个修复程序,所以我安装了
npm生命周期
,但我仍然收到相同的错误。

子模块命令没有内置在基
git.exe
二进制文件中,它是作为名为
git submodule
的shell脚本实现的,它需要从
%PATH%
中访问,并且对于运行操作的用户来说是可执行的

  • 您的npm流程的
    %PATH%
    (或
    %PATH%
    )是什么
  • 它是否包括git安装的路径,它似乎位于
    \Microsoft\TeamFoundation\Team Explorer\git\
    中的某个位置
  • 运行npm进程的用户是否具有对git子模块的执行权限

    • 您可能没有安装Git for windows。我所做的是打开VisualStudio安装程序,然后选择“修改”当前安装,并在“单个组件”选项卡中选中“Git for Windows”(未选中)

      安装后,我没有再次收到相同的错误。

      Git 2.24(2019年第4季度)将修复此错误消息的可能原因,如Windows上所示

      参见(2019年8月24日)作者。
      (于2019年9月30日合并)

      mingw
      :修复从Unicode路径启动外部 如果Git安装在包含非ASCII字符的路径中, 命令,如
      git am
      git submodule
      ,其实现如下 externals将无法启动,并出现以下错误:

      fatal: 'am' appears to be a git command, but we were not able to execute it.  
      Maybe git-am is broken?
      
      这是因为
      lookup\u prog
      不了解Unicode。不知怎么的 中缺少(Win32:Unicode文件名支持(除了
      dirent
      ), 2012年3月15日,Git v2.1.0-rc0)

      请注意,此函数中唯一的问题是调用
      GetFileAttributes()
      而不是
      GetFileAttributesW()

      access()
      的调用很好,因为
      access()
      是一个解析为
      mingw\u access()
      ,它已正确处理Unicode。
      但是
      lookup\u prog()
      被更改为直接使用
      \u waccess()
      ,这样我们只需要 将路径转换为UTF-16一次

      为了使事情正常运行,我们必须在
      lookup\u prog()
      中同时维护UTF-8和UTF-16版本


      我不知道这是否是问题所在,但在您粘贴的命令中,在查看PATH env变量的“-q”选项内有一个空格:
      echo%PATH%
      在windows上,您应该指向“bin”子文件夹。例如,在我的例子中,它是“C:\Program Files\Git\bin”,当然我安装了Git,可能您没有很好地阅读问题,问题的前6个单词是我对您答案的回答,实际上问题与路径有关。:)