npm semver calculator bug?

(Nick Partridge) #1

Hello all,

I am mostly posting this as a question and possible bug in the the npm semver calculator ( It seems that the resolver for prerelease tags is wrong.

The npm semver docs say here

For example, the range >1.2.3-alpha.3 would be allowed to match the version 1.2.3-alpha.7 , but it would not be satisfied by 3.4.5-alpha.9 , even though 3.4.5-alpha.9 is technically “greater than” 1.2.3-alpha.3 according to the SemVer sort rules. The version range only accepts prerelease tags on the 1.2.3 version.

But when you enter the version >1.0.0-rc.1 in the calculator it disregards this and pull all version with or without prerelease tags.

Is this accurate?


(Lars Willighagen) #2

Do you have a specific package where this is happening? The calculator seems to only highlight the right versions when trying it on the npm or vue package.

(John Gee) #3

Were you expecting it to only match prerelease versions, and not higher release versions? I find the wording a little subtle, but there is a specific example in the paragraph you quoted which makes it clear:

For example, the range >1.2.3-alpha.3
The version 3.4.5 would satisfy the range, because it does not have a prerelease flag, and 3.4.5 is greater than 1.2.3-alpha.7 .

(Nick Partridge) #4

@shadowspawn & @larsgw Thanks for the reply. I must have misunderstood the npm docs for prerelease tags.

After reading the docs closer the calculator is working correctly. I just found it strange that the version ^1.0.0-alpha.* would match to 1.0.0-beta.* just because "b" > "a" but I guess that makes sense.

Thanks for the reply, sorry about the trouble.