4

Update for 2020

This question originally referred to the yarn check command, but the docs state that this is deprecated in v1, and removed in v2, and yarn install --check-files should be used instead.

Unfortunately there is still, apparently, no equivalent of the --check-files flag in npm install!


As part of my development build I'd like to check that the versions of dependencies in node_modules are what's expected to be there according to both what's specified in package.json and the lockfile package-lock.json.

In yarn you can do this with yarn install --check-files (or the older deprecated yarn check command in v1)

I am trying to achieve the same using npm.

At the moment I am using npm ci (see docs here) which does work, in the sense that it completely reinstalls node_modules from what's in the lockfile and then errors if the versions in package.json don't match.

But, this is a bit heavyweight and slow. I'm wondering if there is a purely static way to run these checks with npm that doesn't involve cleaning and reinstalling everything on disk?

davnicwil
  • 20,057
  • 9
  • 87
  • 98

0 Answers0