You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] minVersion returns 0.0.0 when a 0.0.0 prerelease is the true minimum #934
This is admittedly a bit pedantic, but minVersion seems to treat 0.0.0 as a special case. A prerelease lower bound is respected on every tuple except 0.0.0:
This comes from the shortcut at the top of ranges/min-version.js, which tries 0.0.0 before 0.0.0-0 and returns the first one that matches.
Expected Behavior
I'd expect '0.0.0-alpha' and '0.0.0-0' respectively, since the README describes minVersion as returning "the lowest version that can match the given range", and the rest of the library agrees that these sort below 0.0.0 (lt, sort, minSatisfying).
I couldn't find anything (docs, tests, or the original PR #241) suggesting 0.0.0 is meant to be special here, so I suspect the shortcut just wasn't written with prerelease lower bounds in mind. But if this is intentional it might be worth documenting.
Steps To Reproduce
npm install semver@7.8.5
Run node -e "console.log(require('semver').minVersion('>=0.0.0-alpha <1.0.0').version)"
See 0.0.0
Environment
npm: 11.20.0
Node: 26.12.1
OS: macOS 26.6.1
platform: Apple Silicon (arm64)
semver: 7.8.5 (same code on main)
AI disclosure: this issue was discovered with AI assistance
I took a look at this. The 0.0.0 shortcut at the top of minVersion returns before the comparators are checked, so >=0.0.0-alpha and 0.0.0-0 with includePrerelease get skipped. I have a small fix with tests that keeps 0.0.0 for the non-prerelease cases. Happy to open a PR if that sounds right.
Activity
ljharb commentedon Oct 28, 2026
When includePrerelease is not true, 0.0.0 is indeed the ultimate minimum, but when it IS true, i'd expect 0.0.0-0.
thelastbackspace commentedon Nov 5, 2026
I took a look at this. The
0.0.0shortcut at the top ofminVersionreturns before the comparators are checked, so>=0.0.0-alphaand0.0.0-0withincludePrereleaseget skipped. I have a small fix with tests that keeps0.0.0for the non-prerelease cases. Happy to open a PR if that sounds right.