The workflow fails at the 'npm ci' step complaining that package-lock.json is out of sync with package.json, even though the build works fine locally.

Keep package-lock.json committed and in sync, and pin the same Node.js version in CI that's used locally.

Step-by-Step Guide

1

Run npm install locally and commit the updated package-lock.json if it drifted

2

Pin the exact Node version with actions/setup-node, matching the local .nvmrc

3

Use npm ci instead of npm install in CI for fully reproducible builds

4

Cache node_modules using actions/cache keyed on the package-lock.json hash

5

Check for OS-specific native dependencies that behave differently on Ubuntu runners

6

Add a build step before tests to catch build errors earlier in the pipeline

7

Review the full Actions log, not just the summary, for the exact npm error message

Found an issue with this solution?

Related Topics

npm ci vs npm installgithub actions cache dependenciescross platform ci differences