antpaw antpaw - 2 months ago 11
Node.js Question

npm peer dependency check

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

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


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.