gpt4 book ai didi

node.js - Docker 容器中的 Gulp 命令代码 139

转载 作者:太空宇宙 更新时间:2023-11-03 22:27:06 27 4
gpt4 key购买 nike

我有这个 docker-compose 文件:

  rest-api:
image: x/rest-api
build:
context: ./rest-api/dockerfiles/
dockerfile: local.Dockerfile
environment:
- BUILD_ENV=local
ports:
- "8001:8001"
volumes:
- ./rest-api:/var/www/rest-api
user: $UID
web:
image: x/web-front
build:
context: ./web-front
dockerfile: dockerfiles/local.Dockerfile
environment:
- BUILD_ENV=local
depends_on:
- rest-api
links:
- rest-api
ports:
- "3001:3001"
- "35729:35729"
volumes:
- ./web-front:/var/www/web-front
- ./web-front/logs/:/root/.npm/
user: $UID

和这2个local.Dockerfile。休息 API:

    FROM node:8-alpine

RUN mkdir -p /var/www/rest-api/
WORKDIR /var/www/rest-api/

EXPOSE 8001

CMD [ "npm", "run", "dev" ]

网页前端:

 FROM node:8-alpine

RUN mkdir -p /var/www/web-front/
WORKDIR /var/www/web-front/

EXPOSE 3001 35729

CMD [ "npm", "run", "local" ]

我基本上从主机安装所有的node_modules,然后将卷映射到容器中的rest-api 和 web-front 的相应文件夹。然后我从容器中运行 package.json 中的命令。我的rest-api 没有遇到任何问题。在 Web 前端思想中,进程退出时出现段错误(核心转储)和错误代码 139

CMD [ "npm", "run", "local" ]

运行:

"NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1",

当我直接在计算机上运行 npm run local 时,我没有这个问题。我已经尝试过npm重建但没有成功容器上的 Node 版本与主机上的版本相同。我有这个调试:

    0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'local' ]
2 info using npm@5.0.0
3 info using node@v8.0.0
4 verbose run-script [ 'prelocal', 'local', 'postlocal' ]
5 info lifecycle web-front@0.5.0~prelocal: web-front@0.5.0
6 silly lifecycle web-front@0.5.0~prelocal: no script for prelocal, continuing
7 info lifecycle web-front@0.5.0~local: web-front@0.5.0
8 verbose lifecycle web-front@0.5.0~local: unsafe-perm in lifecycle true
9 verbose lifecycle web-front@0.5.0~local: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/var/www/web-front/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
10 verbose lifecycle web-front@0.5.0~local: CWD: /var/www/web-front
11 silly lifecycle web-front@0.5.0~local: Args: [ '-c',
11 silly lifecycle 'NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1' ]
12 silly lifecycle web-front@0.5.0~local: Returned: code: 139 signal: null
13 info lifecycle web-front@0.5.0~local: Failed to exec local script
14 verbose stack Error: web-front@0.5.0 local: `NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1`
14 verbose stack Exit status 139
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
14 verbose stack at emitTwo (events.js:125:13)
14 verbose stack at EventEmitter.emit (events.js:213:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:125:13)
14 verbose stack at ChildProcess.emit (events.js:213:7)
14 verbose stack at maybeClose (internal/child_process.js:887:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
15 verbose pkgid web-front@0.5.0
16 verbose cwd /var/www/web-front
17 verbose Linux 4.4.0-66-generic
18 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "local"
19 verbose node v8.0.0
20 verbose npm v5.0.0
21 error code ELIFECYCLE
22 error errno 139
23 error web-front@0.5.0 local: `NODE_ENV=local ./node_modules/gulp/bin/gulp.js dev --location=local --env=dev --livereload=1`
23 error Exit status 139
24 error Failed at the web-front@0.5.0 local script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 139, true ]

您知道这个错误从何而来吗?提前致谢。

最佳答案

此问题是由于 Alpine 造成的。 Alpine 使用 musl 而不是 glibc,这会导致某些库出现问题。使用 debian 或任何其他使用 glibc 的发行版。

关于node.js - Docker 容器中的 Gulp 命令代码 139,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44484685/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com