0

我在尝试重用npm ci在作业之间安装的软件包时遇到了重大问题。我一直在关注此文档:https://docs.gitlab.com/ee/ci/caching/#cache-nodejs-dependencies,但无论如何都会在每个步骤中重新安装软件包:

$ npm ci --cache node_modules --prefer-offline
added 1895 packages, and audited 1896 packages in 41s

这是我的yaml。这些文件位于名为frontend.

stages:
  - lint
  - test
  - build
  
image: node:15-alpine

# Cache modules in between jobs
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - frontend/.npm/

before_script:
  - cd frontend
  - npm ci --cache .npm --prefer-offline

do-lint:
  stage: lint
  script:
    - ./node_modules/.bin/eslint src
    - ./node_modules/.bin/stylelint "src/*.{css,scss}"

test-front-end:
  stage: test
  script:
    # Force tests to run in CI mode
    - CI=true npm test
  coverage: '/^All\sfiles.*?\s+\d+.\d+.*?\s+(\d+.\d+)/'

do-build:
  stage: build
  script:
    - npm run build

非常感谢一些帮助!

4

0 回答 0