NPM and peer dependencies

Nov 17, 2015  

While working on the mai-chai module I realized that I should be using peerDependencies.

The mai-chain module expects that its consumer installs chai, but it does not really depend on it. This package.json excerpt:

1"devDependencies": {
2},
3"dependencies": {
4  "chai": "^3.4.1",
5  "chai-equal-jsx": "^1.0.2",
6  "chai-spies": "^0.7.1",
7  "chai-string": "^1.1.3",
8  "dirty-chai": "^1.2.2"
9}

has to be replaced with the following:

 1"devDependencies": {
 2},
 3"dependencies": {
 4  "chai-equal-jsx": "^1.0.2",
 5  "chai-spies": "^0.7.1",
 6  "chai-string": "^1.1.3",
 7  "dirty-chai": "^1.2.2"
 8},
 9"peerDependencies": {
10  "chai": "^3.4.1"
11}

Note that the reference to chai was moved from dependencies to peerDependencies.