Gitlab runner npm install 命令行出现网络错误

问题描述 投票:0回答:1

我在 k8s 上设置了 Gitlab 和 Gitlab runner。 Gitlab runner已连接到Gitlab实例并正确运行命令。运行作业发布我的 Vuejs 项目后,我在 npm install 命令行中从 gitlab runner 收到网络错误。

这是我的 gitlab-ci.yaml:

build site:
  image: node:lts-alpine
  stage: build
  script:
    - npm install --progress=false
    - npm run build
  artifacts:
    expire_in: 1 week
    paths:
      - dist

这是我的 Gitlab 运行日志:

Running with gitlab-runner 16.6.1 (f5da3c5a)
  on lms-git-runner-01 esosuhkgL, system ID: r_SjhlYAhCSRTB
Preparing the "kubernetes" executor
00:00
Using Kubernetes namespace: gitlab-runner
Using Kubernetes executor with image node:lts-alpine ...
Using attach strategy to execute scripts...
Preparing environment
00:06
Using FF_USE_POD_ACTIVE_DEADLINE_SECONDS, the Pod activeDeadlineSeconds will be set to the job timeout: 1h0m0s...
Waiting for pod gitlab-runner/runner-esosuhkgl-project-1-concurrent-0-bgff4642 to be running, status is Pending
Waiting for pod gitlab-runner/runner-esosuhkgl-project-1-concurrent-0-bgff4642 to be running, status is Pending
    ContainersNotReady: "containers with unready status: [build helper]"
    ContainersNotReady: "containers with unready status: [build helper]"
Running on runner-esosuhkgl-project-1-concurrent-0-bgff4642 via gitlab-runner-8b59c79dc-zmrfb...
Getting source from Git repository
00:03
Fetching changes with git depth set to 20...
Initialized empty Git repository in /builds/frontend/lms-frontend-v3/.git/
Created fresh repository.
Checking out e6aa6709 as detached HEAD (ref is main)...
Skipping Git submodules setup
Executing "step_script" stage of the job script
$ npm install --progress=false
npm ERR! code ECONNRESET
npm ERR! network aborted
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network 
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-12-26T09_21_54_880Z-debug-0.log
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: command terminated with exit code 1

需要正确运行 ci/cd 没有问题。

kubernetes gitlab gitlab-ci-runner
1个回答
0
投票

我的错误是由于当 npm 接收包时,它无法接收其中一个包,它不会重试,按照这些步骤解决了我的问题

首先我使用 npm install 和 --verbose 属性来显示所有安装日志:

npm install --verbose

然后,当您发现任何错误时,使用 --force 选项重试 npm 并继续安装所有 npm 软件包:

npm isntall --verbose --force
© www.soinside.com 2019 - 2024. All rights reserved.