npm ci can only install packages when your package.json and package-lock.json are in sync: how to fix it
npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync (npm error code EUSAGE) means the committed lockfile no longer matches package.json: a dependency was added or changed without re-running npm install, or the lockfile was not committed. Run npm install locally, commit package.json and package-lock.json together, and npm ci passes.
By Livops team, the people who build and run LivopsUpdated
The error people search for, as npm 10 and 11 print it[4][5][6] (shortened; the package names are examples):
npm error code EUSAGE
npm error
npm error `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm error
npm error Missing: [email protected] from lock file
npm error Invalid: lock file's [email protected] does not satisfy [email protected]
The current npm source says the first line without or npm-shrinkwrap.json[7]; it is the same error. This page explains what npm ci checks, lists the ways a lockfile drifts from package.json, gives the fix for each, and shows how to confirm it before you push.
What does the error mean?
npm ci is the install meant for automated environments: CI, tests and deploys[1]. It is strict on purpose:
- the project must have a
package-lock.jsonornpm-shrinkwrap.json[1]; - if the dependencies in the lockfile do not match those in
package.json, it exits with an error instead of updating the lockfile[1]; - it never writes to
package.jsonor the lockfile[1].
npm install does the opposite: when the lockfile and package.json conflict, package.json wins and the lockfile is updated[2]. That is why the error appears on a server and not on your machine: you ran npm install locally, it quietly fixed your lockfile, and that fix never reached the repository.
Read the lines under the message. Each one names a package[5]:
Missing: <pkg>@<version> from lock file—package.json(or a dependency of it) needs a package the lockfile does not have.Invalid: lock file's <pkg>@<old> does not satisfy <pkg>@<new>— the lockfile has a version outside the rangepackage.jsonnow asks for.
npm marks this as a usage error, which is where the code EUSAGE comes from[6].
Causes, most common first
1. package.json changed, the lockfile did not
You edited a version by hand, resolved a merge conflict in package.json only, or a bot bumped a range and the lockfile was left behind. Fix: let npm write the lockfile, then commit both files together:
npm install
git add package.json package-lock.json
git commit -m "Update package-lock.json"
With the lockfile in place, npm install keeps every locked version that still satisfies package.json and resolves only the rest[2]; deleting the lockfile first would let every dependency move.
2. The lockfile is not in the repository
If package-lock.json is in .gitignore, or was never added, the build has none, and npm 11 stops with a different message[4]:
The `npm ci` command can only install with an existing package-lock.json or
npm-shrinkwrap.json with lockfileVersion >= 1.
npm documents the lockfile as a file meant to be committed[3]. Remove it from .gitignore and add it:
git add -f package-lock.json
git commit -m "Commit package-lock.json"
3. A stale npm-shrinkwrap.json
When both npm-shrinkwrap.json and package-lock.json are at the root, the shrinkwrap wins and package-lock.json is ignored[3]. A forgotten npm-shrinkwrap.json from years ago is checked instead of the lockfile you keep updating. Delete it if you do not publish the package with it, then run npm install and commit.
4. Two package managers in one repository
A yarn.lock or pnpm-lock.yaml next to package-lock.json usually means dependencies are added with one tool while the build installs with another. npm ci reads only package-lock.json or npm-shrinkwrap.json[4], so every yarn add or pnpm add leaves it further behind. Fix: pick one manager, delete the other lockfiles, and install with the one you kept:
git rm yarn.lock pnpm-lock.yaml # keeping npm
npm install
git add package-lock.json
5. A different npm major version
The lockfile records the format it was written in: lockfileVersion 1 for npm 5 and 6, 2 for npm 7 and 8, 3 for npm 9 and above[3]. If the error appears only on the server, compare npm -v on both sides. Regenerate the lockfile with the npm major your build uses, so both read and write the same format:
npx npm@11 install # replace 11 with the npm major your build prints
git add package-lock.json
6. Workspaces (monorepos)
package-lock.json is ignored anywhere other than the root project[3], so in a workspaces repository the lockfile that counts is the one at the top. A dependency added inside a workspace folder by hand is not in it. Add it from the root, naming the workspace[8], and commit the root lockfile:
npm install zod -w packages/api
git add package.json packages/api/package.json package-lock.json
The pnpm version: ERR_PNPM_OUTDATED_LOCKFILE
pnpm has the same check. With --frozen-lockfile it fails if the lockfile is out of sync with package.json, and in CI that is the default when a lockfile is present[9]. The error is ERR_PNPM_OUTDATED_LOCKFILE; pnpm’s own fix is to run pnpm install and commit the changed lockfile[10].
How to confirm the fix locally
Run the build’s install from a clean tree. If it passes here, it passes on the server for the same reason:
git status # package-lock.json must not show as modified
rm -rf node_modules
npm ci
To check against the server’s Node and npm rather than yours, run it in a container with the same Node version:
docker run --rm -v "$PWD":/app -w /app node:22 npm ci
On Livops
-
Which install runs. Livops picks the command from the lockfile you committed, in this order:
pnpm-lock.yaml,yarn.lock,bun.lock,package-lock.json. Withpackage-lock.jsonthe log saysFound a npm lockfile — installing exactly those versionsand runsnpm ci; with no lockfile it runsnpm install. -
A second attempt. If
npm cifails, the log saysnpm ci did not work — trying npm install insteadand the install runs again without the strict check. For a pnpm project, the second attempt ispnpm install --no-frozen-lockfile. The deploy can then pass, but with versions npm resolved on the server rather than the ones you tested: fix the lockfile anyway. -
Your own install command runs as written. The second attempt is only for the command Livops chose. If you set Settings → Install, or
installinlivops.json, that command runs exactly as typed, with no fallback:{ "install": "npm ci" } -
When it still fails, the deploy stops as
install_failedand the old version keeps running. Next to the failed build, the assistant’s button reads the log and explains what happened. See Install failed. -
Node version. Livops builds with Node 22 and 24, and reads
.nvmrc,.node-versionanddevEnginesinpackage.json.
Other npm failures, where the real error is above code 1, are in npm error code 1.
Questions
What does npm error code EUSAGE mean here?
EUSAGE is the code npm gives a command that cannot run the way it was called. For npm ci it means the lockfile and package.json disagree, or there is no lockfile at all. The lines under the message say which packages differ.
Can I just run npm install instead of npm ci in the deploy?
It makes the error go away, but npm install updates the lockfile when it disagrees with package.json, so the server may install versions you never tested. Fix the lockfile once and keep npm ci.
Should I delete package-lock.json and start over?
Only as a last resort. Deleting it lets every dependency move to the newest version its range allows. Running npm install with the lockfile in place changes only what package.json asks for.
Why does npm ci pass on my laptop but fail in CI?
Usually the lockfile you fixed locally was never committed, or it is listed in .gitignore. Run git status after npm install and check that package-lock.json is in the commit.
Do I need package-lock.json in Git?
Yes. npm documents it as a file meant to be committed, and npm ci refuses to run without it or npm-shrinkwrap.json.
What is the pnpm version of this error?
ERR_PNPM_OUTDATED_LOCKFILE. In CI pnpm uses a frozen lockfile by default when one is present, and the fix is the same: run pnpm install and commit pnpm-lock.yaml.
Sources
- npm Docs — npm ci (docs.npmjs.com). Checked .
- npm Docs — npm install (docs.npmjs.com). Checked .
- npm Docs — package-lock.json (docs.npmjs.com). Checked .
- npm 11.0.0 source — lib/commands/ci.js (raw.githubusercontent.com). Checked .
- npm 11.0.0 source — lib/utils/validate-lockfile.js (raw.githubusercontent.com). Checked .
- npm 11.0.0 source — lib/base-cmd.js (usageError) (raw.githubusercontent.com). Checked .
- npm source, current release line — lib/commands/ci.js (raw.githubusercontent.com). Checked .
- npm Docs — workspaces (docs.npmjs.com). Checked .
- pnpm — pnpm install (pnpm.io). Checked .
- pnpm — Error codes (pnpm.io). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your Node appRelated
- npm failed with return code 1 (npm ERR! code 1): how to fix the buildnpm failed with return code 1, or npm install exited with 1, is npm ERR! code 1 in newer npm: it only says that a script npm ran exited with code 1. The real error is printed above it: usually a compile or type error, a lockfile out of sync with package.json, or a dependency whose install script failed. Find the first error line above code 1, fix that, and the build passes.
- Node.js hosting in 2026: how to deploy an Express appA Node.js server in production needs one long-running process that listens on the port it is given, restarts when it crashes and exits cleanly on SIGTERM. On Livops you push a repository with package.json and it runs as a web app for 39 credits a month (39,000 so'm). Here is what Node needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.
- JavaScript heap out of memory during next build: how to fix itNode's JavaScript heap reached its limit while Next.js was building, and V8 stopped the process. Raise the heap limit with NODE_OPTIONS=--max-old-space-size, staying below the memory the build really has, and cut what the build holds in memory: source maps, type checking during the build, and heavy dependencies.
- Error: pg_config executable not found (psycopg2): how to fix itError: pg_config executable not found, followed by Failed building wheel for psycopg2, means pip is compiling psycopg2 from source and the machine has no PostgreSQL client headers or pg_config. Switch to a package that needs no compiling, psycopg2-binary or psycopg[binary] for Psycopg 3, or install libpq-dev and a C compiler where the build runs.
- ERR_PNPM_OUTDATED_LOCKFILE: Cannot install with frozen-lockfile because pnpm-lock.yaml is not up to date: how to fix itERR_PNPM_OUTDATED_LOCKFILE means pnpm was told to install exactly what pnpm-lock.yaml says (frozen-lockfile, the default in CI when a lockfile is present), and the lockfile no longer matches a package.json: a dependency was added or changed without re-running pnpm install, or the updated lockfile was never committed. Run pnpm install locally, commit pnpm-lock.yaml, and the install passes.
- YN0028: The lockfile would have been modified by this install, which is explicitly forbidden: how to fix itYN0028 (FROZEN_LOCKFILE_EXCEPTION) means Yarn was running an immutable install, the default on CI, and finishing it would have changed yarn.lock: a dependency was added or changed without re-running yarn install, the updated yarn.lock was not committed, or another Yarn release needs to migrate the lockfile. Run yarn install locally with the project's Yarn version and commit yarn.lock. Yarn 1 says the same with: Your lockfile needs to be updated, but yarn was run with --frozen-lockfile.