npm · npm
The message
npm ERR! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync.
What it means
npm ci installs strictly what the lockfile records, and it stopped before starting because package.json asks for something the lockfile does not contain. It happens when someone hand-edited package.json or resolved a conflict in it without running install, or committed package.json without the lockfile beside it. Run npm install locally once so the lockfile matches, then commit the lockfile — that is the whole fix. Deleting package-lock.json to get past it instead re-resolves every dependency to newer versions and quietly changes what your build contains.
The fix
npm install- Printed by
- npm
- npm
- 20
With npm the cause sits in the first code XXXX line rather than the last six npm ERR! lines, and when the failure comes from the dependency tree or a native build instead of your own code, deleting node_modules and installing again clears about half of them.
Reading an error message
- Read from the first line down. The lower you go the more it is about the tool’s internals; the cause is usually at the top.
- If there is a file and a line number, start there — not the top stack frame, but the topmost line that names a file you wrote.
- Search the message verbatim, but strip your own paths and variable names first; those are what stop the search from matching.
- The same condition is worded differently across tool versions. If results look wrong, add the version number to the query.
- Before pasting a fix, check what it throws away. Some of these cannot be undone.
Common questions
Q. What does “npm ERR! npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync.” mean?
npm ci installs strictly what the lockfile records, and it stopped before starting because package.json asks for something the lockfile does not contain. It happens when someone hand-edited package.json or resolved a conflict in it without running install, or committed package.json without the lockfile beside it. Run npm install locally once so the lockfile matches, then commit the lockfile — that is the whole fix. Deleting package-lock.json to get past it instead re-resolves every dependency to newer versions and quietly changes what your build contains.
Q. How do I fix it?
npm install — before running it, check the explanation above for what this command discards.
Q. Which tool prints this?
npm. It sits under npm, and the message runs to 18 words.