category: npm title: Peer Dependencies date: 2013-02-08T00:00:00Z author: Domenic Denicola slug: peer-dependencies Reposted from [Domenic's blog](http://domenic.me/2013/02/08/peer-dependencies/) with permission. Thanks! npm is awesome as a package manager. In particular, it handles sub-dependencies very well: if my package depends on `request` version 2 and `some-other-library`, but `some-other-library` depends on `request` version 1, the resulting dependency graph looks like: ```text ├── request@2.12.0 └─┬ some-other-library@1.2.3 └── request@1.9.9 ``` This is, generally, great: now `some-other-library` has its own copy of `request` v1 that it can use, while not interfering with my package's v2 copy. Everyone's code works! ## The Problem: Plugins There's one use case where this falls down, however: *plugins*. A plugin package is meant to be used with another "host" package, even though it does not always directly *use* the host package. There are many examples of this pattern in the Node.js package ecosystem already: - Grunt [plugins](http://gruntjs.com/#plugins-all) - Chai [plugins](http://chaijs.com/plugins) - LevelUP [plugins](https://github.com/rvagg/node-levelup/wiki/Modules) - Express [middleware](http://expressjs.com/api.html#middleware) - Winston [transports](https://github.com/flatiron/winston/blob/master/docs/transports.md) Even if you're not familiar with any of those use cases, surely you recall "jQuery plugins" from back when you were a client-side developer: little `