简体   繁体   English

docker容器中的npm安装不起作用

[英]npm install in docker container not working

I'm trying to dockarize my application (angular as frontend and node js express as backend).我正在尝试对我的应用程序进行对接(角度作为前端,节点 js 表示作为后端)。 Therefore I built these two Dockerfiles and this docker-compose File:因此,我构建了这两个 Dockerfile 和这个 docker-compose 文件:

docker-compose:码头工人撰写:

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

Dockerfile (Frontend) 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 (Backend) 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"]

After that I tried to built the docker container with docker-compose build and then I get the following error.之后,我尝试使用docker-compose build docker 容器,然后出现以下错误。 Something is just not working with the npm install , but I don't know what.有些东西不能与npm install一起使用,但我不知道是什么。 Did someone of you have seen that problem?你们中有人看到过这个问题吗? I'd appreciate any help - thanks!我将不胜感激 - 谢谢!

=> 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

I had the same issue, figured out the cause我也遇到了同样的问题,找到原因了

How to figure out what package is breaking by you:如何确定您正在破坏什么包裹:

  • Remove line by line in package.json and try to install在 package.json 中逐行删除并尝试安装
  • After understanding which package it is, downgrade the version until it is installed了解是哪个包后,降级版本,直到安装
  • Then check the package's package.json to check what changed然后检查包的 package.json 以检查发生了什么变化

By me ember-fetch was the cause of the problem.对我来说, ember-fetch是问题的原因。
The reason to the fail was a dep of dep Merge pull request #125 from xg-wang/rollup_iife · ember-cli/ember-fetch@7199051失败的原因是来自 xg-wang/rollup_iife 的 dep 合并请求 #125 · ember-cli/ember-fetch@7199051

ember-fetch uses rollup-plugin-babel since version 5.1.2 which is not locked to a specific version that one of its updates fails npm 3 / node 6. ember-fetch从版本 5.1.2 开始使用rollup-plugin-babel ,该版本未锁定到其更新之一失败的特定版本 npm 3 / node 6。

The solution was reverting to version ember-fetch to 5.1.1 which isn't suppose to cause any breaking change.该解决方案将版本 ember-fetch 恢复到 5.1.1,这不会导致任何重大更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM