问题
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.
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/35061525/check-versions-in-package-json-against-actual-node-modules