'submodule'似乎是一个git命令,但我们无法执行它

时间:2019-02-13 14:01:23

标签: node.js git visual-studio npm npm-install

我已经克隆了一个git存储库,它是一个Angular 7 ASP.NET应用程序,项目中的一切都很好,但是当我尝试还原npm软件包时,出现以下错误。

  

\ Microsoft \ TeamFoundation \ Team Explorer \ Git \ cmd \ git.EXE子模块   更新-q --init --recursive       致命的:'submodule'似乎是一个git命令,但我们不是       能够执行它。也许git-submodule坏了吗?        在ChildProcess.exithandler(child_process.js:291:12)        在ChildProcess.emit(events.js:182:13)        在也许关闭(internal / child_process.js:961:16)        在Process.ChildProcess._handle.onexit(内部/child_process.js:248:5)        npm ERR! cb()从未调用过!

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"
  }
}

我安装的node-version10.7.0,而npm-version6.4.1

我在GitHub上发现了类似的问题,他们在npm-lifecycle中添加了一个修复程序,因此我安装了npm-lifecycle,但仍然遇到相同的错误

3 个答案:

答案 0 :(得分:2)

submodule命令没有内置到基本的git.exe二进制文件中,它以名为git-submodule的shell脚本实现,需要从%PATH%进行访问,并对执行该操作的用户可执行。

  • 您的%PATH%(或您的npm流程的%PATH%)是什么?
  • 它是否包括您的git安装路径,该路径似乎位于\Microsoft\TeamFoundation\Team Explorer\Git\中?
  • 运行npm进程的用户是否对git-submodule拥有执行权限?

答案 1 :(得分:1)

Git 2.24(2019年第四季度)将解决此错误消息的可能原因,在Windows上可以看到。

请参见commit 4e1a641Adam Roben (aroben)(2019年8月24日)。
(由Junio C Hamano -- gitster --commit 6f21347中合并,2019年9月30日)

  

mingw:修复了从Unicode路径启动外部事件的问题

     

如果Git安装在包含非ASCII字符的路径中,   git amgit submodule之类的命令,它们被实现为   外部,将无法启动并显示以下错误:

fatal: 'am' appears to be a git command, but we were not able to execute it.  
Maybe git-am is broken?
     

这是由于lookup_prog不支持Unicode。不知何故   在85faec9中丢失(Win32:Unicode文件名支持(dirent除外),   2012-03-15,Git v2.1.0-rc0)。

     

请注意,此函数中唯一的问题是调用   GetFileAttributes(),而不是GetFileAttributesW()
  对access()的调用很好,因为access()是一个宏,它解析为   mingw_access(),它已经可以正确处理Unicode。
  但是lookup_prog()已更改为直接使用_waccess(),因此我们只   一次将路径转换为UTF-16。

     

要使事情正常运行,我们必须在lookup_prog()中同时维护UTF-8和UTF-16版本。

答案 2 :(得分:0)

可能您没有安装用于Windows的Git。我所做的,似乎对我有用的是打开Visual Studio安装程序,然后选择“修改”当前安装,然后从“单个组件”选项卡中选中“ Git for Windows”(未选中)。

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

相关问题