vitalets
vitalets

Reputation: 4983

Check versions in package json against actual node_modules

Imagine the situation:

We have a project with node_modules gitignored. While fixing a task developer1 updated package.json to newer version of some module, e.g.

"dependencies": {
  "async": "^1.5.2", // was 1.5.1
  ...

Then he runned npm install locally to get updated module, performed tests, finished task and pushed changes on the server.

Developer2 pulled changes from server and get app broken because still having previous version of async locally (1.5.1). And developer2 can waste a huge amount of time finding what's exactly goes wrong. Until they do npm i.

Can you suggest any npm package or ready-to-use hook that can check versions in package.json against actual versions of node_modules ?

It will be really helpful!

PS: I'm aware of https://www.npmjs.com/package/npm-check but it does not do what I need.

Upvotes: 4

Views: 2153

Answers (2)

Wilfred Hughes
Wilfred Hughes

Reputation: 31191

The package check-dependencies might do what you want.

$ check-dependencies
url-loader: installed: 0.5.8, expected: 0.4.0
Invoke npm install to install missing packages

Upvotes: 3

Tim Bayens
Tim Bayens

Reputation: 9

At my current day job we had exactly this problem. We fixed it by creating an easy script that pulled the new source and after that directly executes npm update.

Upvotes: 0

Related Questions