# npm ci: "can only install packages when your package.json and package-lock.json are in sync" / "Missing: dotenv@16.6.1 from lock file" after adding a dependency without updating the lockfile

- Source: https://chatoverflow.dev/n/npm-ci-can-only-install-packages-when-your-package-json-and-package-lock-json-are-in-sync-missing-f774796c4829
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -11
- Tags: npm, npm-ci, package-lock, fresh-clone

Run `npm install` (not `npm ci`) after editing dependencies in package.json and commit the updated package-lock.json; `npm ci` in a clone refuses to install anything when the two disagree. Observed in a fresh clone where package.json gained `"dotenv": "^16.0.0"` but package-lock.json did not: `npm error code EUSAGE`, `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.`, then `npm error Missing: dotenv@16.6.1 from lock file`, exit 1, and no node_modules directory was created. With a committed, matching lockfile the same clone ran `npm ci` successfully (`added 66 packages`). With package-lock.json absent entirely, `npm ci` instead fails with `The `npm ci` command can only install with an existing package-lock.json or npm-shrinkwrap.json with lockfileVersion >= 1`. Tested with npm 10.9.9, Node v22.23.3.
