How to properly update npm peer dependencies?

5.3k views Asked by At

I have an npm package A which has a peer dependency on package B:

"peerDependencies": {
   "B": "^0.4.0",
}

I also have a Node.js project C which use A as a plain dependency.

Since I installed A in C with:

npm install A --save 

This means I also have B installed as a peer dependency with the latest version which is compatible to 0.4.0.

What happens when a new minor version of B released? Let's say B 0.5.0 comes out.

This is still compatible to A (at least according to SemVer), so I don't want to update my package B because B should still work with 0.4.x. I don't want to restrict the users of my package A to use 0.5.0 from B just because I like using latest versions.

But in my own project C I'd still prefer to use the latest version of B.

What can I do?

I thought that

npm update B

should work (i.e. update peer dependency B to its latest version which is still compatible with my dependencies), but it does nothing.

0

There are 0 answers