npm 对等依赖检查 [英] npm peer dependency check

查看:62
本文介绍了npm 对等依赖检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ npm install
my_module@0.0.1 /Users/antpaw/my_module
├── my_module@0.0.1 
└── UNMET PEER DEPENDENCY request@^2.74.0

npm WARN my_module@0.0.1 requires a peer of request@^2.74.0 but none was installed.

我不明白这怎么可能只是一个警告.如果没有安装请求"并且我的应用程序将崩溃,这对我的应用程序来说是一件大事.

I don't understand how this can be only a warning. It's a pretty big deal for my app if "request" isn't install and my app will crash.

如果对等依赖项未满足或者是否有类似 npm do-i-have-everything-i 的东西,我如何让 npm install1 退出-need-installed 命令会以 1 退出?

How can i make npm install exit with 1 if a peer dependency is unmet or is there something like npm do-i-have-everything-i-need-installed command that will exit with 1?

推荐答案

看起来我已经找到了一种使用 1 退出的方法,after/before(我认为顺序无关紧要)) 执行一般的 npm install 我需要运行 npm install my_module,它将以 1 退出.这意味着我可以定义一个模块列表,我想确保在我的 CI 脚本中有他们需要的东西(在 peerDependencies 中定义),虽然不漂亮但总比没有好.

It looks like I've found a way to exit with 1, after/before (I think the order doesn't matter) doing the general npm install I need to run npm install my_module which will exit with 1. That means I can define a list of modules I want to make sure to have exactly what they need (defined in peerDependencies) in my CI script, not pretty but it's better than nothing.

所以 npm install 不会破坏你在 package.json 中定义的无意义的依赖关系.npm install module_name 如果您的 package.json 中有废话,将会中断.

So npm install doesn't break no matter what kind of dependencies nonsense you will define in your package.json. npm install module_name will break if you have nonsense in your package.json.

这篇关于npm 对等依赖检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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