【问题标题】:Running npm install get a error with gitlab-ci on Docker在 Docker 上运行 npm install 时出现 gitlab-ci 错误
【发布时间】:2020-04-26 10:19:20
【问题描述】:

我正在尝试在命令行中使用 gitlab-ci 进行构建,运行 npm install 时出现以下错误。

$ npm install
158 > uws@9.14.0 install /builds/Digistarts/petlig-admin/node_modules/uws
159 > node-gyp rebuild > build_log.txt 2>&1 || exit 0
160 > grpc@1.18.0 install /builds/Digistarts/petlig-admin/node_modules/grpc
161 > node-pre-gyp install --fallback-to-build --library=static_library
162 node-pre-gyp WARN Using request for node-pre-gyp https download 
163 node-pre-gyp WARN Tried to download(404): https://node-precompiled-binaries.grpc.io/grpc/v1.18.0/node-v72-linux-x64-musl.tar.gz 
164 node-pre-gyp WARN Pre-built binaries not found for grpc@1.18.0 and node@12.14.0 (node-v72 ABI, musl) (falling back to source compile with node-gyp) 
165 gyp ERR! build error 
166 gyp ERR! stack Error: not found: make
167 gyp ERR! stack     at getNotFoundError (/usr/lib/node_modules/npm/node_modules/which/which.js:13:12)
168 gyp ERR! stack     at F (/usr/lib/node_modules/npm/node_modules/which/which.js:68:19)
169 gyp ERR! stack     at E (/usr/lib/node_modules/npm/node_modules/which/which.js:80:29)
170 gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/which/which.js:89:16
171 gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/isexe/index.js:42:5
172 gyp ERR! stack     at /usr/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
173 gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:158:21)
174 gyp ERR! System Linux 4.19.78-coreos
175 gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=/builds/Digistarts/petlig-admin/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node" "--module_name=grpc_node" "--module_path=/builds/Digistarts/petlig-admin/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
176 gyp ERR! cwd /builds/Digistarts/petlig-admin/node_modules/grpc
177 gyp ERR! node -v v12.14.0
178 gyp ERR! node-gyp -v v5.0.5
179 gyp ERR! not ok 
180 node-pre-gyp ERR! build error 
181 node-pre-gyp ERR! stack Error: Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/builds/Digistarts/petlig-admin/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/builds/Digistarts/petlig-admin/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
182 node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/builds/Digistarts/petlig-admin/node_modules/grpc/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
183 node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:210:5)
184 node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
185 node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
186 node-pre-gyp ERR! System Linux 4.19.78-coreos
187 node-pre-gyp ERR! command "/usr/bin/node" "/builds/Digistarts/petlig-admin/node_modules/grpc/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
188 node-pre-gyp ERR! cwd /builds/Digistarts/petlig-admin/node_modules/grpc
189 node-pre-gyp ERR! node -v v12.14.0
190 node-pre-gyp ERR! node-pre-gyp -v v0.12.0
191 node-pre-gyp ERR! not ok 
192 Failed to execute '/usr/bin/node /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --library=static_library --module=/builds/Digistarts/petlig-admin/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl/grpc_node.node --module_name=grpc_node --module_path=/builds/Digistarts/petlig-admin/node_modules/grpc/src/node/extension_binary/node-v72-linux-x64-musl --napi_version=5 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
193 npm WARN app@0.0.0 No description
194 npm WARN app@0.0.0 No repository field.
195 npm WARN app@0.0.0 No license field.
196 npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
197 npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
198 npm ERR! code ELIFECYCLE
199 npm ERR! errno 1
200 npm ERR! grpc@1.18.0 install: `node-pre-gyp install --fallback-to-build --library=static_library`
201 npm ERR! Exit status 1
202 npm ERR! 
203 npm ERR! Failed at the grpc@1.18.0 install script.
204 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
205 npm ERR! A complete log of this run can be found in:
206 npm ERR!     /root/.npm/_logs/2020-01-08T20_09_43_203Z-debug.log
207 ERROR: Job failed: exit code 1

我已经尝试安装 node-pre-gyp 但同样的错误。它刚刚停止工作。它工作了一年。我的 CI 配置如下。

image: docker:latest

services:
- docker:dind

before_script:
  - apk add --no-cache curl jq python py-pip
  - apk add --no-cache bash
  - apk add --update ruby-dev
  #- gem install compass
  - apk add --update nodejs nodejs-npm
  - apk add --no-cache git
  - node -v
  - npm -v
  - npm install
  - npm install -g gulp bower
  - gulp -v
  - bower install --allow-root
  - pip install awscli

stages:
  - build
  - build-staging
  - build-dev

build:
  stage: build
  script:
    - ./build.sh
    - ./deploy.sh production `cat VERSION`
  only:
    - master

build-staging:
  stage: build-staging
  script:
    - ./build.sh
    - ./deploy.sh staging `cat VERSION`
  only:
    - staging

build-dev:
  stage: build-dev
  script:
    - ./build.sh
    - ./deploy.sh development `cat VERSION`
  only:
    - develop

【问题讨论】:

    标签: docker npm node-modules gitlab-ci


    【解决方案1】:

    在 before_script 之后添加波纹管脚本

      before_script:
        - apk add g++ make python
    

    【讨论】:

      【解决方案2】:

      您在 alpine 映像中遗漏了一些构建要求

      gyp ERR! stack Error: not found: make
      

      通过在“before_script”下添加以下命令来安装这些工具:

      apk add --virtual build-dependencies build-base gcc
      

      【讨论】:

      • 另外记得重建 docker 容器以确保安装了这个依赖项
      • 这里有同样的错误。问题可能是什么? npm 错误! grpc@1.18.0 安装脚本失败。
      猜你喜欢
      • 2022-12-07
      • 2020-02-20
      • 1970-01-01
      • 2022-01-12
      • 2018-02-07
      • 2019-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多