docker 镜像内用 npm install 报错:enoent undefined ls-remote -h -t https://github.com/jquery/jquery-ui.git

环境

  • node: 12.18.0
  • npm: 6.14.4
  • docker: 19.03.11-ce
  • base_image: alpine linux 3.11

在容器里边使用npm install报错如下信息:

npm WARN tar ENOENT: no such file or directory, open '/app/frontend/node_modules/.staging/karma-firefox-launcher-b4f3b1ff/package.json'
npm WARN tar ENOENT: no such file or directory, open '/app/frontend/node_modules/.staging/karma-firefox-launcher-b4f3b1ff/CHANGELOG.md'
npm WARN tar ENOENT: no such file or directory, lstat '/app/frontend/node_modules/.staging/mark.js-34a11f21/test/fixtures'
npm WARN tar ENOENT: no such file or directory, open '/app/frontend/node_modules/.staging/mark.js-34a11f21/test/manual.html'
npm WARN tar ENOENT: no such file or directory, lstat '/app/frontend/node_modules/.staging/mark.js-34a11f21/test/specs'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/@angular/compiler-cli/node_modules/fsevents):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename
'/app/frontend/node_modules/.staging/fsevents-1fa34a5d/node_modules/abbrev' -> '/app/frontend/node_modules/.staging/abbrev-f0f601f6'

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://github.com/jquery/jquery-ui.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!     /root/.npm/_logs/2020-06-15T08_51_52_246Z-debug.log

原因

npm ERR! enoent undefined ls-remote -h -t https://github.com/jquery/jquery-ui.git 这条报错信息可以看出,这里调用了ls-remote命令,这是git的子命令,因为打包镜像的时候没有安装git,所以导致报错了。

解决办法

打包镜像时把git装上

点赞

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注