Skip to content

Update about-semantic-versioning.mdx to clarify version resolution and pre-releases #1655

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ For example, to specify acceptable version ranges up to 1.0.4, use the following

For more information on semantic versioning syntax, see the [npm semver calculator][semver-calc].

<Note>

**Note:** When using version ranges in your `package.json`, npm resolves to the **highest available version** that satisfies the specified constraints. This behavior ensures that consumers automatically receive the most recent compatible stable release, as long as the changes remain within the defined semver range. Pre-release versions (e.g., `1.2.0-beta.1`) are ignored unless explicitly requested or allowed via specific configuration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that if your range includes a prerelease then new prereleases will be included.
example from semver.npmjs.com showing >11.0.0-pre.0 including 11.0.0-pre.1

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your input! You're absolutely right that when the version range explicitly includes a prerelease version — like >11.0.0-pre.0 — then further prereleases will be considered as valid candidates.

My contribution was intended to reflect the default behavior when the version range does not explicitly include a prerelease version — for example, using ^1.0.0 or ~2.2.0. In those cases, even if a prerelease version exists within the semantic range (like 1.1.0-beta.0), npm install will not install it unless:

  • the prerelease is explicitly included in the version range, or
  • the version is installed directly via npm install some-lib@1.1.0-beta.0.

This behavior has even led to some confusion in the community, as discussed in npm/cli#7851, where users expected >x.y.z-beta to include later prereleases — but npm does not currently resolve those by default.

This distinction between stable and prerelease resolution isn't always obvious, so I thought it would be helpful to clarify. Happy to refine the wording further if needed!

</Note>

### Example

```json
Expand Down