Sometimes people change package.json
and forget to run npm i
which will update package-lock.json
, or package.json
and package-lock.json
are otherwise out of sync. This is an assumption not to be discussed/questioned here. I am looking for a tool that helps detect such cases.
Do you know of an npm feature or third-party tool that can sanity-check package-lock.json
? For example, it should resolve all transitive dependencies, and check that they all are mentioned in the lock file with a version in the correct semver range. It should tell whether it would make sense to run npm i
in order to update your lockfile, or also whether npm ci
would get you all the dependencies required as defined in package.json
(accounting for transitivity).
I thought that npm --loglevel verbose install --dry-run
would be a reasonable candidate, but its output does not mention what it would do to package-lock.json
in case it would be run without --dry-run
. Of course one option would be to run npm i
and then git diff package-lock.json
(or similar), but that's dirty.