React项目CI流水线执行npm ci报错,求解决方案
React项目CI流水线npm ci执行失败求助
近期给React项目添加了.yml配置文件,npm ci命令在本地机器运行完全正常,但CI流水线执行该命令时持续报错。
已尝试的解决方法
- 怀疑
package.json与package-lock.json不同步,删除lock文件后执行npm install --package-lock-only重新生成,但在对应PR中仍失败; - 将Node版本限定为本地使用的18.x版本,问题依旧。
.yml配置文件内容
name: Build and Test React Application # Controls when the action will run. on: # Triggers the workflow on push or pull request events but only for the main branch push: branches: [ "main" ] pull_request: branches: [ "main" ] # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build_test: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 - name: Use Node.js 18.x uses: actions/setup-node@v3 with: node-version: 18.x cache: 'npm' - name: npm ci, build and test run: | npm ci npm run build --if-present npm test - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v3 env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
报错调试信息
Run npm ci npm ci npm run build --if-present npm test shell: /usr/bin/bash -e {0} npm ERR! code EUSAGE npm ERR! npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing. npm ERR! npm ERR! Invalid: lock file's ajv@6.12.6 does not satisfy ajv@8.12.0 npm ERR! Missing: ajv@6.12.6 from lock file npm ERR! Invalid: lock file's json-schema-traverse@0.4.1 does not satisfy json-schema-traverse@1.0.0 npm ERR! Missing: ajv@6.12.6 from lock file npm ERR! Missing: typescript@4.9.5 from lock file npm ERR! Missing: ajv@6.12.6 from lock file npm ERR! Missing: ajv-keywords@3.5.2 from lock file npm ERR! Missing: json-schema-traverse@0.4.1 from lock file npm ERR! Missing: ajv@6.12.6 from lock file npm ERR! Missing: ajv-keywords@3.5.2 from lock file npm ERR! Missing: json-schema-traverse@0.4.1 from lock file npm ERR! Missing: json-schema-traverse@0.4.1 from lock file npm ERR! Missing: ajv@6.12.6 from lock file npm ERR! Missing: ajv-keywords@3.5.2 from lock file npm ERR! Missing: json-schema-traverse@0.4.1 from lock file npm ERR! Missing: json-schema-traverse@0.4.1 from lock file npm ERR! npm ERR! Clean install a project npm ERR! npm ERR! Usage: npm ERR! npm ci npm ERR! npm ERR! Options: npm ERR! [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling] npm ERR! [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]] npm ERR! [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit] npm ERR! [--no-bin-links] [--no-fund] [--dry-run] npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]] npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links] npm ERR! npm ERR! aliases: clean-install, ic, install-clean, isntall-clean npm ERR! npm ERR! Run "npm help ci" for more info npm ERR! A complete log of this run can be found in: /home/runner/.npm/_logs/2023-10-04T21_35_18_017Z-debug-0.log Error: Process completed with exit code 1.
请问有谁知道该如何解决或尝试其他方法吗?
内容的提问来源于stack exchange,提问作者aheed
相关产品推荐
相关产品推荐

