assert-package-lock-is-consistent

Assert that package-lock.json is consistent with package.json

Usage no npm install needed!

<script type="module">
  import assertPackageLockIsConsistent from 'https://cdn.skypack.dev/assert-package-lock-is-consistent';
</script>

README

assert-package-lock-is-consistent

NPM version dependencies: none code style: prettier Conventional Commits License MIT

Assert that package-lock.json is consistent with package.json, that is, both files have the same dependencies.

Install

Requires node@14 or higher:

npm install assert-package-lock-is-consistent --save-dev

Usage

This package verifies that package-lock.json and package.json files in your project have the same dependencies (dependencies, devDependencies, peerDependencies, and optionalDependencies).

If some dependency exists only in one file, or if the versions of some dependency in these files are different, the package throws an exception with a list of all such differences (prints a list and returns code 1 in CLI).

Dependency versions may difference if someone, for example, forgets to update package-lock.json file or include it in a commit.

The package works with package-lock.json file version 2 (npm@7 or higher).

CLI

Assert that package-lock.json has the same dependencies as package.json:

npx assert-package-lock-is-consistent

JavaScript/TypeScript API

import assertPackageLockIsConsistent from 'assert-package-lock-is-consistent';
// or
import {assertPackageLockIsConsistent} from 'assert-package-lock-is-consistent';

// assert that package-lock.json has the same dependencies as package.json
assertPackageLockIsConsistent();

License

MIT