Konstantin Kuznetsov
Konstantin Kuznetsov

Reputation: 903

What is wrong with this npm semver?

I want do add following dependency to package.json of my npm package:

"redux-saga": "^1.0.0-beta.0 || ^0.16.0"`.

So when I install this package of mine inside different project that already has

"redux-saga": "^1.0.0-beta.1

I expect npm/yarn to install only 1.0.0-beta.1 inside project's node_modules. However, it installs 0.16.0 transitively inside my package.

So I checked with semver calculator and got weird results for redux-saga package:

I could not find any explanation in docs. My question is - if it's not a bug, then why ^1.0.0-beta.0 || ^0.16.0 does not allow 1.0.0-beta.1?

Upvotes: 1

Views: 361

Answers (1)

Konstantin Kuznetsov
Konstantin Kuznetsov

Reputation: 903

My question has been answered on npm community forums.

0.16.0 gets installed because it is tagged latest, and npm prioritizes latest tag. The algorithm can be found in npm-pick-manifest package.

I ended up using yarn resolutions to solve versions conflict

Upvotes: 1

Related Questions