根据实际 node_modules 检查包 json 中的版本 [英] Check versions in package json against actual node_modules

查看:56
本文介绍了根据实际 node_modules 检查包 json 中的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

想象一下情况:

我们有一个node_modules gitignored 的项目.在修复任务时 developer1package.json 更新为某些模块的较新版本,例如

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
  ...

然后他在本地运行 npm install 以获取更新的模块、执行测试、完成任务并在服务器上推送更改.

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

Developer2 从服务器中提取更改并导致应用程序损坏,因为本地仍然具有以前版本的 async (1.5.1).而且 developer2 可能会浪费大量时间来查找究竟出了什么问题.直到他们执行 npm i.

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.

你能推荐任何 npm 包或现成的钩子,可以根据 node_modules 的实际版本检查 package.json 中的版本吗?

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

这真的很有帮助!

PS:我知道 https://www.npmjs.com/package/npm-check 但它没有做我需要的.

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

推荐答案

check-dependencies 可以做你想做的事.

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

这篇关于根据实际 node_modules 检查包 json 中的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆