Fixing the “are in sync” error from npm ci
When npm ci stops with `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync., the dependencies written in package.json do not match what is recorded in package-lock.json. Run npm install once to update package-lock.json, then commit that package-lock.json together with package.json, and npm ci will pass.
This error appears when you add a dependency to package.json by hand or change a version range, push without updating package-lock.json, and then npm ci fails in CI (GitHub Actions and similar) or in a deploy step. I reproduced the error in a test environment, recorded the full message, and confirmed that the fix below makes it go away.
The test environment was Ubuntu 24.04. I mainly tested with Node.js 22.23.4 (npm 10.9.9). For comparison I also ran the same steps with npm 11.19.1, which ships with Node.js 24.22.1, and with npm 9.9.4. The examples use lodash, ms, and is-number, and the registry is the default registry.npmjs.org. I did not test Windows, macOS, real CI services such as GitHub Actions, yarn, pnpm, or projects that use workspaces.
The full error message
I created a project with npm init -y, installed lodash with npm install lodash@^4.17.21, and got a state where package.json and package-lock.json matched. Then I added "ms": "^2.1.3" to package.json only and ran npm ci. With npm 10.9.9 it stopped with the following output (exit code 1). In the output shown here, I replaced the log file path with ~/.npm/_logs and the project path with /path/to/app.
$ npm ci
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: ms@2.1.3 from lock file
npm error
npm error Clean install a project
npm error
npm error Usage:
npm error npm ci
npm error
npm error Options:
npm error [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling]
npm error [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]]
npm error [--include <prod|dev|optional|peer> [--include <prod|dev|optional|peer> ...]]
npm error [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit]
npm error [--no-bin-links] [--no-fund] [--dry-run]
npm error [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]]
npm error [-ws|--workspaces] [--include-workspace-root] [--install-links]
npm error
npm error aliases: clean-install, ic, install-clean, isntall-clean
npm error
npm error Run "npm help ci" for more info
npm error A complete log of this run can be found in: ~/.npm/_logs/2026-11-13T05_36_01_142Z-debug-0.log
You only need to read line 3 of the output (the `npm ci` can only install packages… line) and line 5 (the Missing: line). Everything from Clean install a project down is the usage text for npm ci. In the npm 10.9.9 source, this error is created by a function called usageError. That function attaches the code EUSAGE and appends the usage text after the message.
Line 3 means: "npm ci can only install packages when the contents of package.json and package-lock.json (or npm-shrinkwrap.json) match. Before continuing, update the lock file with npm install." Line 5 lists what differs, one item per line.
With npm 11.19.1, lines 3 and 5 were the same sentences. The usage text is longer and lists every option, so the line explaining the reason ends up much higher in the output. With npm 9.9.4, lines 3 and 5 started with npm ERR! instead of npm error, but the sentences were the same.
npm ERR! `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 ERR!
npm ERR! Missing: ms@2.1.3 from lock file
The project is not changed by the error
After this error stopped the command, package-lock.json was unchanged. I compared it with a copy I had saved before adding ms, using cmp, and the two files were identical. The existing node_modules was also untouched: lodash was still installed in it.
The official npm ci documentation says that npm ci deletes node_modules if it exists before starting, that it exits with an error without updating the lock file when the dependencies in package.json and the lock file do not match, and that it never writes to package.json or the lock file. In the npm 10.9.9 source, node_modules is deleted only after the check against the lock file has passed. So with npm 10.9.9, this error does not leave node_modules empty.
Running npm ci again stops with the same error as long as package.json and package-lock.json stay the same.
Reading Missing and Invalid to see what differs
In my tests, line 5 showed one of two forms:
| Form of line 5 | What is happening |
|---|---|
Missing: ms@2.1.3 from lock file |
A dependency in package.json is not in package-lock.json |
Invalid: lock file's lodash@4.18.1 does not satisfy lodash@3.10.1 |
The version recorded in package-lock.json is outside the range written in package.json |
Missing appears when you add a dependency to package.json. The 2.1.3 in ms@2.1.3 is the version npm picked as matching the range ^2.1.3 written in package.json.
Invalid appears when you change the range of a dependency that was already there. In my test, lodash 4.18.1 was installed, and I changed the lodash entry in package.json to ^3.10.1 and ran npm ci. After does not satisfy, the message shows 3.10.1, which is the version npm picked as matching that range, not the range ^3.10.1 itself.
When there is more than one difference, one line appears for each. In another project with lodash and ms 2.1.3 installed, I changed the ms range to ~2.0.0 and added is-number, then ran npm ci. Two lines appeared:
npm error Missing: is-number@7.0.0 from lock file
npm error Invalid: lock file's ms@2.1.3 does not satisfy ms@2.0.0
In the npm 10.9.9 source, npm builds a list of dependencies from package.json and compares each one with package-lock.json. Entries missing from the lock file are shown as Missing, and entries with a different version are shown as Invalid, all printed together.
When changing the range does not cause an error
If you change the range in package.json but the version recorded in package-lock.json still falls inside it, npm ci does not fail. With lodash 4.18.1 in the lock file, I changed the range to ^4.0.0. npm ci passed and installed 4.18.1, the version in the lock file.
Removing a dependency from package.json did not cause an error either. I removed ms from package.json and ran npm ci. package-lock.json still listed ms, but only lodash was installed.
Running npm install to update the lock file clears the error
As the message says, run npm install with no arguments once. It rewrote package-lock.json to match package.json, and ms was added.
$ npm install
added 1 package, and audited 3 packages in 361ms
found 0 vulnerabilities
After that, npm ci finished without an error (exit code 0).
$ npm ci
added 2 packages, and audited 3 packages in 475ms
found 0 vulnerabilities
$ npm ls
app@1.0.0 /path/to/app
+-- lodash@4.18.1
`-- ms@2.1.3
In the case with both Missing and Invalid, npm install changed ms in package-lock.json to 2.0.0 and added is-number. Then npm ci finished without an error. With npm 11.19.1, npm ci after npm install also finished without an error.
When CI fails this way, run npm install locally, then commit the updated package-lock.json together with package.json and push.
Updating only the lock file without installing into node_modules
npm install --package-lock-only updates package-lock.json only, without installing anything into node_modules. The official npm install documentation says that with this option, npm uses only package-lock.json and ignores node_modules.
In my test, I added ms to package.json, deleted node_modules, and confirmed that npm ci stopped with exit code 1. Then I ran this command:
$ npm install --package-lock-only
up to date, audited 3 packages in 381ms
found 0 vulnerabilities
$ ls node_modules 2>&1
ls: cannot access 'node_modules': No such file or directory
node_modules was not created, but package-lock.json now included ms. The npm ci I ran afterward finished without an error.
When there is no package-lock.json at all, the message is different
Running npm ci in a project without package-lock.json did not stop with the are in sync message. It stopped with the following message instead (usage text omitted):
$ npm ci
npm error code EUSAGE
npm error
npm error The `npm ci` command can only install with an existing package-lock.json or
npm error npm-shrinkwrap.json with lockfileVersion >= 1. Run an install with npm@5 or
npm error later to generate a package-lock.json file, then try again.
As the official documentation says, npm ci always requires package-lock.json or npm-shrinkwrap.json. Create package-lock.json first by running npm install or a similar command, then run npm ci.





