Builds download npm packages each time. Configure caching correctly in GitLab.

BeginnerScenarioGitLab CI
Answer

Situation read → Cache vs artifacts confusion.

What I'd do →

cache:
  key:
    files: [package-lock.json]
  paths: [.npm/]
  policy: pull-push
variables:
  npm_config_cache: "$CI_PROJECT_DIR/.npm"

Use policy: pull in jobs that only read.

Why → Caches speed up dependencies and are best-effort; artifacts pass results between jobs.

Interview tip → Cache is not guaranteed; the build must still work without it.

All CI/CD questions Roadmap: GitLab CI/CD

More on GitLab CI