Self-service
Describe the bug
Hi!
So I've encountered a problem while trying to bump a version from x.(y+1).z-a to x.(y+1).z, having a stable version x.y.z.
If the patch number z is not 0, the command yarn version x.(y+1).z will instead bump the patch number instead of the minor number, resulting in version x.y.(z+1) in the package.json file.
To reproduce
- Have a
package.json file with the following:
{
"name": "test-version",
"version": "1.3.1-alpha",
"main": "index.js",
"license": "MIT",
"packageManager": "yarn@4.1.1",
"stableVersion": "1.2.1"
}
- Use a yarn version with the
yarn version command available (I used yarn@4.1.1)
- execute
yarn version 1.3.1
- verify that the version got bumped to the wrong number,
1.2.2
{
"name": "test-version",
"version": "1.2.2",
"main": "index.js",
"license": "MIT",
"packageManager": "yarn@4.1.1"
}
Environment
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M1
Binaries:
Node: 24.11.1 - /private/var/folders/c3/1ys3y2l901vd82nm685_59mc0000gn/T/xfs-d118fb53/node
Yarn: 4.1.1 - /private/var/folders/c3/1ys3y2l901vd82nm685_59mc0000gn/T/xfs-d118fb53/yarn
npm: 11.6.2 - /Users/mfeldman/.nvm/versions/node/v24.11.1/bin/npm
bun: 1.0.0 - /opt/homebrew/bin/bun
Additional context
I've tested something and might found that the problem might be on this function. When testing for the suggested strategy, when having both the from version and the to version be the same version (regardless of the prerelease version), it will always return a patch:

Self-service
Describe the bug
Hi!
So I've encountered a problem while trying to bump a version from
x.(y+1).z-atox.(y+1).z, having a stable versionx.y.z.If the patch number
zis not0, the commandyarn version x.(y+1).zwill instead bump the patch number instead of the minor number, resulting in versionx.y.(z+1)in the package.json file.To reproduce
package.jsonfile with the following:{ "name": "test-version", "version": "1.3.1-alpha", "main": "index.js", "license": "MIT", "packageManager": "yarn@4.1.1", "stableVersion": "1.2.1" }yarn versioncommand available (I used yarn@4.1.1)yarn version 1.3.11.2.2{ "name": "test-version", "version": "1.2.2", "main": "index.js", "license": "MIT", "packageManager": "yarn@4.1.1" }Environment
System: OS: macOS 14.4.1 CPU: (8) arm64 Apple M1 Binaries: Node: 24.11.1 - /private/var/folders/c3/1ys3y2l901vd82nm685_59mc0000gn/T/xfs-d118fb53/node Yarn: 4.1.1 - /private/var/folders/c3/1ys3y2l901vd82nm685_59mc0000gn/T/xfs-d118fb53/yarn npm: 11.6.2 - /Users/mfeldman/.nvm/versions/node/v24.11.1/bin/npm bun: 1.0.0 - /opt/homebrew/bin/bunAdditional context
I've tested something and might found that the problem might be on this function. When testing for the suggested strategy, when having both the
fromversion and thetoversion be the same version (regardless of the prerelease version), it will always return a patch: