Updates the package version.
Using the yarn version
command you can update the version of your package via
the command line.
For example, starting with this package.json package.json
:
{
"name": "example-yarn-package",
"version": "1.0.1",
"description": "An example package to demonstrate Yarn"
}
When we run the yarn version
command:
yarn version
info Current version: 1.0.1
question New version: 1.0.2
info New version: 1.0.2
✨ Done in 9.42s.
We will get this updated package.json
:
{
"name": "example-yarn-package",
"version": "1.0.2",
"description": "An example package to demonstrate Yarn"
}
Note: The new version you enter must be a valid SemVer version.
If you run yarn version
within a Git repository a
Git tag will be created by
default following the format v0.0.0
.
You can customize the git tag that is created or disable this behavior by using
yarn config set
.
To change the prefix of the git tag you can use version-tag-prefix
:
yarn config set version-tag-prefix "v"
Or you can change the git message using version-git-message
where %s
is the
version string:
yarn config set version-git-message "v%s"
You can also turn signing git tags on or off using version-git-sign
:
yarn config set version-git-sign false
You can even enabled or disable the git tagging behavior entirely by using
version-git-tag
:
yarn config set version-git-tag true
yarn version
Create a new version using an interactive session to prompt you for a new version.
yarn version --new-version <version>
Creates a new version specified by <version>
.
yarn version --no-git-tag-version
Creates a new version without creating a git tag.
← Previous: yarn upgrade Next: yarn why →