Skip to content

yarn version

apply a new version to the current package

Terminal window
yarn version <strategy>

Immediately bump the version to the next major :

Terminal window
yarn version major

Prepare the version to be bumped to the next major :

Terminal window
yarn version major --deferred

This command will bump the version number for the given package, following the specified strategy:

  • If major, the first number from the semver range will be increased (X.0.0).

  • If minor, the second number from the semver range will be increased (0.X.0).

  • If patch, the third number from the semver range will be increased (0.0.X).

  • If prefixed by pre (premajor, …), a -0 suffix will be set (0.0.0-0).

  • If prerelease, the suffix will be increased (0.0.0-X); the third number from the semver range will also be increased if there was no suffix in the previous version.

  • If decline, the nonce will be increased for yarn version check to pass without version bump.

  • If a valid semver range, it will be used as new version.

  • If unspecified, Yarn will ask you for guidance.

For more information about the --deferred flag, consult our documentation (https://yarnpkg.com/features/release-workflow#deferred-versioning).

DefinitionDescription

-d,—deferred

Prepare the version to be bumped during the next release cycle

-i,—immediate

Bump the version immediately
any single member of your team inside the same project - by doing this you
ensure that you have control over Yarn upgrades and downgrades (including on
your deployment servers), and get rid of most of the headaches related to
someone using a slightly different version and getting different behavior.

The version specifier can be:

  • a tag:

  • latest / berry / stable -> the most recent stable berry (>=2.0.0) release

  • canary -> the most recent canary (release candidate) berry (>=2.0.0) release

  • classic -> the most recent classic (^0.x || ^1.x) release

  • a semver range (e.g. 2.x) -> the most recent version satisfying the range (limited to berry releases)

  • a semver version (e.g. 2.4.1, 1.22.1)

  • a local file referenced through either a relative or absolute path

  • self -> the version used to invoke the command

DefinitionDescription

—yarn-path

Set the yarnPath setting even if the version can be accessed by Corepack

—only-if-needed

Only lock the Yarn version if it isn’t already locked