← Verse · A-to-Mind · Fix an automation

GitHub Actions "npm ci can only install packages when package.json and package-lock.json are in sync": the fix

You see: npm ci can only install packages when your package.json and package-lock.json are in sync ยท Process completed with exit code 1

What it means

npm ci installs exactly what package-lock.json lists and refuses to run if that file does not match package.json. Someone changed a dependency in package.json without updating the lock file, or the lock file was made with a different npm version.

How to fix it

  1. On your computer run npm install in the project, so the lock file is rewritten to match package.json.
  2. Commit package-lock.json and push. Make sure it is not in .gitignore.
  3. Pin the same Node version in the workflow that you use locally with the setup-node action, so the lock file format matches: uses: actions/setup-node@v4 with node-version set to your version.
  4. Re-run the workflow.

If it keeps coming back

If it comes back, two people are on different npm versions. Agree on one (an .nvmrc file or the engines field) and use it in the workflow.

Still stuck? Ask Verse, free

Paste the error and what the automation does. Verse names the likely cause and the fix, in seconds, no account.

Ask Verse about this error

Or have it fixed: $25

One broken automation, diagnosed and repaired, with proof it runs again. Reply to the receipt with what stopped.

Get the One-Time Fix

The One-Time Fix covers one workflow. What you send and what you get back.

Sources