antpaw antpaw - 2 years ago 330
Node.js Question

npm peer dependency check

$ npm install
[email protected] /Users/antpaw/my_module
├── [email protected]
└── UNMET PEER DEPENDENCY [email protected]^2.74.0

npm WARN [email protected] requires a peer of [email protected]^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.

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

Answer Source

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.

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download