[英]What is wrong with this npm semver?
I want do add following dependency to package.json of my npm package:我想在我的 npm 包的 package.json 中添加以下依赖项:
"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
.我希望 npm/yarn 在项目的
node_modules
只安装1.0.0-beta.1
node_modules
。 However, it installs 0.16.0
transitively inside my package.但是,它会在我的包中传递地安装
0.16.0
。
So I checked with semver calculator and got weird results for redux-saga
package:所以我检查了semver 计算器并得到了
redux-saga
包的奇怪结果:
^1.0.0-beta.0 || ^0.16.0
^1.0.0-beta.0 || ^0.16.0
only allows 0.16.0
- this is unexpected ^1.0.0-beta.0 || ^0.16.0
只允许0.16.0
- 这是意外^1.0.0-beta.0 || ^0.15.0
^1.0.0-beta.0 || ^0.15.0
allows expected ^1.0.0-beta.0 || ^0.15.0
允许预期
0.15.0 0.15.1 0.15.2 0.15.3 0.15.4 0.15.5 0.15.6 1.0.0-beta.0 1.0.0-beta.1
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
我的问题是 - 如果它不是错误,那么为什么
^1.0.0-beta.0 || ^0.16.0
^1.0.0-beta.0 || ^0.16.0
does not allow 1.0.0-beta.1
? ^1.0.0-beta.0 || ^0.16.0
不允许1.0.0-beta.1
吗?
My question has been answered on npm community forums .我的问题已在 npm 社区论坛上得到解答。
0.16.0
gets installed because it is tagged latest
, and npm prioritizes latest
tag. 0.16.0
被安装,因为它被标记为latest
,并且 npm 优先考虑latest
标记。 The algorithm can be found in npm-pick-manifest package.该算法可以在npm-pick-manifest包中找到。
I ended up usingyarn resolutions to solve versions conflict我最终使用纱线分辨率来解决版本冲突
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.