Skip to content

fix(plugin-npm): resolve "*" to prereleases when no stable version exists#7205

Open
arpitjain099 wants to merge 1 commit into
yarnpkg:masterfrom
arpitjain099:chore/npm-star-prerelease
Open

fix(plugin-npm): resolve "*" to prereleases when no stable version exists#7205
arpitjain099 wants to merge 1 commit into
yarnpkg:masterfrom
arpitjain099:chore/npm-star-prerelease

Conversation

@arpitjain099

@arpitjain099 arpitjain099 commented Jun 27, 2026

Copy link
Copy Markdown

What's the problem this PR addresses?

Installing a package whose only published versions are prereleases fails with YN0082: No candidates found when the range is *. The reported case is @microsoft/kiota-abstractions@npm:*, where every registry version is a prerelease. A stable * never matching a prerelease is correct semver, but it leaves these packages uninstallable until a stable release exists.

In #6469 @arcanis agreed with retrying using includePrerelease when the range is * and nothing matched, rather than treating * as latest:

I think it'd make sense to tolerate the prerelease versions until at least one stable is released. We can't make * tolerate all prerelease everytime though, it wouldn't match semver (and would break backward compatibility).

Closes #6469.

How did you fix it?

Pulled the version matching out of NpmSemverResolver.getCandidates into a selectMatchingVersions helper. It matches as before, and only when the range is exactly * and the normal match is empty does it retry with new semver.Range('*', {includePrerelease: true}). Any other range (say ^1.0.0) keeps its current behavior and still won't pick up prereleases.

Tests in NpmSemverResolver.test.ts: with the fix removed the prerelease-only * case returns [], and with it the prereleases come back; ^1.0.0 against a prerelease-only set stays [], and a * against a set with stable versions still ignores prereleases. yarn jest packages/plugin-npm/tests/NpmSemverResolver.test.ts passes.

One thing left out on purpose: getSatisfying uses the same default-range filter, so a prerelease locked this way could fail to re-satisfy * on a later resolution. That felt like a separate change from the install path here, so I held off, but happy to follow up if you want it covered too.

Checklist

  • I have read the Contributing Guide.
  • I have set the packages that need to be released for my changes to be effective.
  • I will check that all automated PR checks pass before the PR gets reviewed.

…ists

A stable "*" range never matches a prerelease, so a package whose only
published versions are prereleases fails to resolve with YN0082 (no
candidates found). When the requested range is exactly "*" and nothing
matched, retry the version selection with includePrerelease so the
package can still be installed until a stable release is published.

The retry is scoped strictly to the "*" case, so every other range keeps
its current semver behavior.

Closes yarnpkg#6469

Signed-off-by: Arpit Jain <arpitjain099@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug?]: YN0082: │ @microsoft/kiota-abstractions@npm:*: No candidates found

1 participant