0

I'm having significant problems trying to reuse the packages installed with npm ci between jobs. I have been following this documentation: https://docs.gitlab.com/ee/ci/caching/#cache-nodejs-dependencies, but the packages are reinstalled each step anyway:

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

Here's my yaml. The files are within a folder called 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

Would very much appreciate some assistance!

Ben K
  • 11
  • 1

0 Answers0