NPM安装在docker容器不工作



我试图dockarize我的应用程序(角作为前端和节点js express作为后端)。因此,我构建了这两个dockerfile和这个docker-compose File:

docker-compose:

version: "3.8"
services:
frontend:
build: ./Frontend
ports:
- 4200:4200
backend:
build: ./Backend
ports:
- 3000:3000

Dockerfile(前端)

FROM node:6
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm cache clean
RUN npm install
COPY . /usr/src/app
EXPOSE 4200
CMD ["npm","start"]

Dockerfile(后端)

FROM node:6
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json /usr/src/app
RUN npm cache clean
RUN npm install
COPY . /usr/src/app
EXPOSE 3000
CMD ["npm","start"]

之后,我试图用docker-compose build构建docker容器,然后我得到以下错误。npm install有点不对劲,但我不知道是什么。你们有人见过这个问题吗?我很感激任何帮助-谢谢!

=> ERROR [docker_backend 6/7] RUN npm install                                                                    52.4s
=> CANCELED [docker_frontend 6/7] RUN npm install                                                                52.4s
------
> [docker_backend 6/7] RUN npm install:
#0 52.01 Application_Name@1.0.0 /usr/src/app
#0 52.01 +-- cookie-parser@1.4.6
#0 52.01 | +-- cookie@0.4.1
#0 52.01 | `-- cookie-signature@1.0.6
#0 52.01 +-- cron@2.0.0
#0 52.01 | `-- luxon@1.28.0
#0 52.01 +-- csv-parse@5.2.0
#0 52.01 +-- dotenv@16.0.1
#0 52.01 +-- express@4.18.1
#0 52.01 | +-- accepts@1.3.8
#0 52.01 | | +-- mime-types@2.1.35
#0 52.01 | | | `-- mime-db@1.52.0
#0 52.01 | | `-- negotiator@0.6.3
#0 52.01 | +-- array-flatten@1.1.1
#0 52.01 | +-- body-parser@1.20.0
#0 52.01 | | +-- bytes@3.1.2
#0 52.01 | | +-- destroy@1.2.0
#0 52.01 | | +-- iconv-lite@0.4.24
#0 52.01 | | | `-- safer-buffer@2.1.2
#0 52.01 | | +-- raw-body@2.5.1
#0 52.01 | | `-- unpipe@1.0.0
#0 52.01 | +-- content-disposition@0.5.4
#0 52.01 | +-- content-type@1.0.4
#0 52.01 | +-- cookie@0.5.0
#0 52.01 | +-- debug@2.6.9
#0 52.01 | | `-- ms@2.0.0
#0 52.01 | +-- depd@2.0.0
#0 52.01 | +-- encodeurl@1.0.2
#0 52.01 | +-- escape-html@1.0.3
#0 52.01 | +-- etag@1.8.1
#0 52.01 | +-- finalhandler@1.2.0
#0 52.01 | +-- fresh@0.5.2
#0 52.01 | +-- http-errors@2.0.0
#0 52.01 | | +-- inherits@2.0.4
#0 52.01 | | `-- toidentifier@1.0.1
#0 52.01 | +-- merge-descriptors@1.0.1
#0 52.01 | +-- methods@1.1.2
#0 52.01 | +-- on-finished@2.4.1
#0 52.01 | | `-- ee-first@1.1.1
#0 52.01 | +-- parseurl@1.3.3
#0 52.01 | +-- path-to-regexp@0.1.7
#0 52.01 | +-- proxy-addr@2.0.7
#0 52.01 | | +-- forwarded@0.2.0
#0 52.01 | | `-- ipaddr.js@1.9.1
#0 52.01 | +-- qs@6.10.3
#0 52.01 | | `-- side-channel@1.0.4
#0 52.01 | |   +-- call-bind@1.0.2
#0 52.01 | |   | `-- function-bind@1.1.1
#0 52.01 | |   +-- get-intrinsic@1.1.2
#0 52.01 | |   | +-- has@1.0.3
#0 52.01 | |   | `-- has-symbols@1.0.3
#0 52.01 | |   `-- object-inspect@1.12.2
#0 52.01 | +-- range-parser@1.2.1
#0 52.01 | +-- safe-buffer@5.2.1
#0 52.01 | +-- send@0.18.0
#0 52.01 | | +-- mime@1.6.0
#0 52.01 | | `-- ms@2.1.3
#0 52.01 | +-- serve-static@1.15.0
#0 52.01 | +-- setprototypeof@1.2.0
#0 52.01 | +-- statuses@2.0.1
#0 52.01 | +-- type-is@1.6.18
#0 52.01 | | `-- media-typer@0.3.0
#0 52.01 | +-- utils-merge@1.0.1
#0 52.01 | `-- vary@1.1.2
#0 52.01 +-- express-session@1.17.3
#0 52.01 | +-- cookie@0.4.2
#0 52.01 | +-- on-headers@1.0.2
#0 52.01 | `-- uid-safe@2.1.5
#0 52.01 |   `-- random-bytes@1.0.0
#0 52.01 +-- express-validator@5.3.1
#0 52.01 | +-- lodash@4.17.21
#0 52.01 | `-- validator@10.11.0
#0 52.01 +-- node-fetch@3.2.6
#0 52.01 | +-- data-uri-to-buffer@4.0.0
#0 52.01 | +-- fetch-blob@3.1.5
#0 52.01 | | +-- node-domexception@1.0.0
#0 52.01 | | `-- web-streams-polyfill@3.2.1
#0 52.01 | `-- formdata-polyfill@4.0.10
#0 52.01 +-- nodemon@2.0.16
#0 52.01 | +-- chokidar@3.5.3
#0 52.01 | | +-- anymatch@3.1.2
#0 52.01 | | | `-- picomatch@2.3.1
#0 52.01 | | +-- braces@3.0.2
#0 52.01 | | | `-- fill-range@7.0.1
#0 52.01 | | |   `-- to-regex-range@5.0.1
#0 52.01 | | |     `-- is-number@7.0.0
#0 52.01 | | +-- glob-parent@5.1.2
#0 52.01 | | +-- is-binary-path@2.1.0
#0 52.01 | | | `-- binary-extensions@2.2.0
#0 52.01 | | +-- is-glob@4.0.3
#0 52.01 | | | `-- is-extglob@2.1.1
#0 52.01 | | +-- normalize-path@3.0.0
#0 52.01 | | `-- readdirp@3.6.0
#0 52.01 | +-- debug@3.2.7
#0 52.01 | | `-- ms@2.1.3
#0 52.01 | +-- ignore-by-default@1.0.1
#0 52.01 | +-- minimatch@3.1.2
#0 52.01 | | `-- brace-expansion@1.1.11
#0 52.01 | |   +-- balanced-match@1.0.2
#0 52.01 | |   `-- concat-map@0.0.1
#0 52.01 | +-- pstree.remy@1.1.8
#0 52.01 | +-- semver@5.7.1
#0 52.01 | +-- supports-color@5.5.0
#0 52.01 | | `-- has-flag@3.0.0
#0 52.01 | +-- touch@3.1.0
#0 52.01 | | `-- nopt@1.0.10
#0 52.01 | |   `-- abbrev@1.1.1
#0 52.01 | +-- undefsafe@2.0.5
#0 52.01 | `-- update-notifier@5.1.0
#0 52.01 |   +-- boxen@5.1.2
#0 52.01 |   | +-- ansi-align@3.0.1
#0 52.01 |   | +-- camelcase@6.3.0
#0 52.01 |   | +-- cli-boxes@2.2.1
#0 52.01 |   | +-- string-width@4.2.3
#0 52.01 |   | | +-- emoji-regex@8.0.0
#0 52.01 |   | | +-- is-fullwidth-code-point@3.0.0
#0 52.01 |   | | `-- strip-ansi@6.0.1
#0 52.01 |   | |   `-- ansi-regex@5.0.1
#0 52.01 |   | +-- type-fest@0.20.2
#0 52.01 |   | +-- widest-line@3.1.0
#0 52.01 |   | `-- wrap-ansi@7.0.0
#0 52.01 |   +-- chalk@4.1.2
#0 52.01 |   | +-- ansi-styles@4.3.0
#0 52.01 |   | | `-- color-convert@2.0.1
#0 52.01 |   | |   `-- color-name@1.1.4
#0 52.01 |   | `-- supports-color@7.2.0
#0 52.01 |   |   `-- has-flag@4.0.0
#0 52.01 |   +-- configstore@5.0.1
#0 52.01 |   | +-- dot-prop@5.3.0
#0 52.01 |   | | `-- is-obj@2.0.0
#0 52.01 |   | +-- graceful-fs@4.2.10
#0 52.01 |   | +-- make-dir@3.1.0
#0 52.01 |   | | `-- semver@6.3.0
#0 52.01 |   | +-- unique-string@2.0.0
#0 52.01 |   | | `-- crypto-random-string@2.0.0
#0 52.01 |   | `-- write-file-atomic@3.0.3
#0 52.01 |   |   +-- imurmurhash@0.1.4
#0 52.01 |   |   +-- is-typedarray@1.0.0
#0 52.01 |   |   +-- signal-exit@3.0.7
#0 52.01 |   |   `-- typedarray-to-buffer@3.1.5
#0 52.01 |   +-- has-yarn@2.1.0
#0 52.01 |   +-- import-lazy@2.1.0
#0 52.01 |   +-- is-ci@2.0.0
#0 52.01 |   | `-- ci-info@2.0.0
#0 52.01 |   +-- is-installed-globally@0.4.0
#0 52.01 |   | +-- global-dirs@3.0.0
#0 52.01 |   | | `-- ini@2.0.0
#0 52.01 |   | `-- is-path-inside@3.0.3
#0 52.01 |   +-- is-npm@5.0.0
#0 52.01 |   +-- is-yarn-global@0.3.0
#0 52.01 |   +-- latest-version@5.1.0
#0 52.01 |   | `-- package-json@6.5.0
#0 52.01 |   |   +-- got@9.6.0
#0 52.01 |   |   | +-- @sindresorhus/is@0.14.0
#0 52.01 |   |   | +-- @szmarczak/http-timer@1.1.2
#0 52.01 |   |   | | `-- defer-to-connect@1.1.3
#0 52.01 |   |   | +-- cacheable-request@6.1.0
#0 52.01 |   |   | | +-- clone-response@1.0.2
#0 52.01 |   |   | | +-- get-stream@5.2.0
#0 52.01 |   |   | | +-- http-cache-semantics@4.1.0
#0 52.01 |   |   | | +-- keyv@3.1.0
#0 52.01 |   |   | | | `-- json-buffer@3.0.0
#0 52.01 |   |   | | +-- lowercase-keys@2.0.0
#0 52.01 |   |   | | +-- normalize-url@4.5.1
#0 52.01 |   |   | | `-- responselike@1.0.2
#0 52.01 |   |   | +-- decompress-response@3.3.0
#0 52.01 |   |   | +-- duplexer3@0.1.4
#0 52.01 |   |   | +-- get-stream@4.1.0
#0 52.01 |   |   | | `-- pump@3.0.0
#0 52.01 |   |   | |   `-- end-of-stream@1.4.4
#0 52.01 |   |   | +-- lowercase-keys@1.0.1
#0 52.01 |   |   | +-- mimic-response@1.0.1
#0 52.01 |   |   | +-- p-cancelable@1.1.0
#0 52.01 |   |   | +-- to-readable-stream@1.0.0
#0 52.01 |   |   | `-- url-parse-lax@3.0.0
#0 52.01 |   |   |   `-- prepend-http@2.0.0
#0 52.01 |   |   +-- registry-auth-token@4.2.1
#0 52.01 |   |   | `-- rc@1.2.8
#0 52.01 |   |   |   +-- deep-extend@0.6.0
#0 52.01 |   |   |   +-- ini@1.3.8
#0 52.01 |   |   |   `-- strip-json-comments@2.0.1
#0 52.01 |   |   +-- registry-url@5.1.0
#0 52.01 |   |   `-- semver@6.3.0
#0 52.01 |   +-- pupa@2.1.1
#0 52.01 |   | `-- escape-goat@2.1.1
#0 52.01 |   +-- semver@7.3.7
#0 52.01 |   +-- semver-diff@3.1.1
#0 52.01 |   | `-- semver@6.3.0
#0 52.01 |   `-- xdg-basedir@4.0.0
#0 52.01 +-- passport@0.5.3
#0 52.01 | +-- passport-strategy@1.0.0
#0 52.01 | `-- pause@0.0.1
#0 52.01 +-- passport-azure-ad@4.3.3
#0 52.01 | +-- async@3.2.4
#0 52.01 | +-- base64url@3.0.1
#0 52.01 | +-- bunyan@1.8.15
#0 52.01 | | +-- dtrace-provider@0.8.8
#0 52.01 | | | `-- nan@2.16.0
#0 52.01 | | +-- moment@2.29.3
#0 52.01 | | +-- mv@2.1.1
#0 52.01 | | | +-- mkdirp@0.5.6
#0 52.01 | | | | `-- minimist@1.2.6
#0 52.01 | | | +-- ncp@2.0.0
#0 52.01 | | | `-- rimraf@2.4.5
#0 52.01 | | |   `-- glob@6.0.4
#0 52.01 | | |     +-- inflight@1.0.6
#0 52.01 | | |     | `-- wrappy@1.0.2
#0 52.01 | | |     +-- once@1.4.0
#0 52.01 | | |     `-- path-is-absolute@1.0.1
#0 52.01 | | `-- safe-json-stringify@1.2.0
#0 52.01 | +-- cache-manager@3.6.3
#0 52.01 | | +-- async@3.2.3
#0 52.01 | | +-- lodash.clonedeep@4.5.0
#0 52.01 | | `-- lru-cache@6.0.0
#0 52.01 | |   `-- yallist@4.0.0
#0 52.01 | +-- https-proxy-agent@5.0.1
#0 52.01 | | +-- agent-base@6.0.2
#0 52.01 | | | `-- debug@4.3.4
#0 52.01 | | |   `-- ms@2.1.2
#0 52.01 | | `-- debug@4.3.4
#0 52.01 | |   `-- ms@2.1.2
#0 52.01 | +-- jws@3.2.2
#0 52.01 | | `-- jwa@1.4.1
#0 52.01 | |   +-- buffer-equal-constant-time@1.0.1
#0 52.01 | |   `-- ecdsa-sig-formatter@1.0.11
#0 52.01 | +-- node-jose@2.1.1
#0 52.01 | | +-- buffer@6.0.3
#0 52.01 | | | +-- base64-js@1.5.1
#0 52.01 | | | `-- ieee754@1.2.1
#0 52.01 | | +-- es6-promise@4.2.8
#0 52.01 | | +-- long@5.2.0
#0 52.01 | | +-- node-forge@1.3.1
#0 52.01 | | +-- pako@2.0.4
#0 52.01 | | +-- process@0.11.10
#0 52.01 | | `-- uuid@8.3.2
#0 52.01 | +-- oauth@0.9.15
#0 52.01 | +-- passport@0.4.1
#0 52.01 | `-- valid-url@1.0.9
#0 52.01 `-- xmlbuilder@15.1.1
#0 52.01
#0 52.02 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
#0 52.02 npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
#0 52.02 npm WARN Application_Name@1.0.0 No description
#0 52.02 npm WARN Application_Name@1.0.0 No repository field.
#0 52.02 npm ERR! Linux 5.10.16.3-microsoft-standard-WSL2
#0 52.02 npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
#0 52.02 npm ERR! node v6.17.1
#0 52.02 npm ERR! npm  v3.10.10
#0 52.02 npm ERR! path /usr/src/app/node_modules/.staging/@types/node-6a765968/package.json
#0 52.02 npm ERR! code ENOTDIR
#0 52.02 npm ERR! errno -20
#0 52.02 npm ERR! syscall open
#0 52.02
#0 52.02 npm ERR! ENOTDIR: not a directory, open '/usr/src/app/node_modules/.staging/@types/node-6a765968/package.json'
#0 52.02 npm ERR!
#0 52.02 npm ERR! If you need help, you may report this error at:
#0 52.02 npm ERR!     <https://github.com/npm/npm/issues>
#0 52.07
#0 52.07 npm ERR! Please include the following file with any support request:
#0 52.07 npm ERR!     /usr/src/app/npm-debug.log

我有同样的问题,找出原因

如何找出你正在破坏的包:

  • 在包中逐行删除。并尝试安装
  • 在了解它是哪个包之后,降级版本直到它被安装。
  • 然后检查包的包。查看

By meember-fetch是问题的原因。
失败的原因是来自xg-wang/rollup_iife·ember-cli/ember-fetch@7199051的deep of deep Merge pull request #125

ember-fetch使用rollup-plugin-babel,因为版本5.1.2没有锁定到一个特定的版本,其中一个更新失败的npm 3/node 6。

解决方案是将ember-fetch版本恢复到5.1.1,这应该不会导致任何破坏性更改。

最新更新