Check versions in package json against actual node_modules

青春壹個敷衍的年華 提交于 2019-12-10 19:08:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!