# 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.

Source: https://livops.dev/en/guides/error-npm-ci-lockfile-out-of-sync

By Livops team, the people who build and run Livops. Updated 1 December 2026.

The error people search for, as npm 10 and 11 print it[4][5][6] (shortened; the package names are examples):

```text
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: zod@3.23.8 from lock file
npm error Invalid: lock file's react@18.3.1 does not satisfy react@19.0.0
```

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.json` or `npm-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.json` or 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 range `package.json` now 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:

```sh
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]:

```text
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:

```sh
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:

```sh
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:

```sh
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:

```sh
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:

```sh
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:

```sh
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`. With `package-lock.json` the log says `Found a npm lockfile — installing exactly those versions` and runs `npm ci`; with no lockfile it runs `npm install`.
- **A second attempt.** If `npm ci` fails, the log says `npm ci did not work — trying npm install instead` and the install runs again without the strict check. For a pnpm project, the second attempt is `pnpm 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 `install` in `livops.json`, that command runs exactly as typed, with no fallback:

  ```json
  {
    "install": "npm ci"
  }
  ```

- **When it still fails**, the deploy stops as `install_failed` and the old version keeps running. Next to the failed build, the assistant's button reads the log and explains what happened. See [Install failed](https://livops.dev/en/docs/error-install).
- **Node version.** Livops builds with Node 22 and 24, and reads `.nvmrc`, `.node-version` and `devEngines` in `package.json`.

Other npm failures, where the real error is above `code 1`, are in [npm error code 1](https://livops.dev/en/guides/error-npm-exit-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

1. [npm Docs — npm ci](https://docs.npmjs.com/cli/v11/commands/npm-ci/). Checked 1 December 2026.
2. [npm Docs — npm install](https://docs.npmjs.com/cli/v11/commands/npm-install/). Checked 1 December 2026.
3. [npm Docs — package-lock.json](https://docs.npmjs.com/cli/v11/configuring-npm/package-lock-json/). Checked 1 December 2026.
4. [npm 11.0.0 source — lib/commands/ci.js](https://raw.githubusercontent.com/npm/cli/v11.0.0/lib/commands/ci.js). Checked 1 December 2026.
5. [npm 11.0.0 source — lib/utils/validate-lockfile.js](https://raw.githubusercontent.com/npm/cli/v11.0.0/lib/utils/validate-lockfile.js). Checked 1 December 2026.
6. [npm 11.0.0 source — lib/base-cmd.js (usageError)](https://raw.githubusercontent.com/npm/cli/v11.0.0/lib/base-cmd.js). Checked 1 December 2026.
7. [npm source, current release line — lib/commands/ci.js](https://raw.githubusercontent.com/npm/cli/latest/lib/commands/ci.js). Checked 1 December 2026.
8. [npm Docs — workspaces](https://docs.npmjs.com/cli/v11/using-npm/workspaces/). Checked 1 December 2026.
9. [pnpm — pnpm install](https://pnpm.io/cli/install). Checked 1 December 2026.
10. [pnpm — Error codes](https://pnpm.io/errors). Checked 1 December 2026.
