| Feature | yarn version | npm version | | :--- | :--- | :--- | | Git tag format | v1.0.0 (fixed) | v1.0.0 (default, configurable) | | Pre-commit hook | None (requires clean git state) | Supports preversion , version , postversion scripts | | Custom commit message | --message flag | --message flag |
# Starting version: 1.0.0 yarn version --patch package.json version becomes 1.0.1 Git tag: v1.0.1 Bump minor version yarn version --minor package.json version becomes 1.1.0 Bump major version yarn version --major package.json version becomes 2.0.0 Set explicit version yarn version --new-version 3.0.0-beta.1 yarn version
1. Overview
| Error | Likely Cause | Solution | | :--- | :--- | :--- | | Working tree has uncommitted changes | Git repository has modified files. | Commit or stash changes before running. | | Not a git repository | Project not initialized with Git. | Run git init . Use --no-git-tag-version to skip. | | Invalid version | --new-version value is not semantic. | Use valid semver (e.g., 1.2.3 , 2.0.0-beta.1 ). | | Feature | yarn version | npm version
The yarn version command is a built-in Yarn (Classic) CLI command used to manage a project's version number. It automates the process of updating the version field in the package.json file, creating a corresponding Git tag, and optionally committing the change. | | Not a git repository | Project not initialized with Git
Use yarn version for simple, automated version bumping in CI or release scripts. For complex monorepos or modern Yarn (v2+), prefer the workflow. Always push tags manually after verifying the release. Report generated based on Yarn Classic (v1.x) behavior.
| Command / Option | Description | | :--- | :--- | | yarn version | Interactive prompt to select the new version (patch, minor, major, or custom). | | yarn version --new-version <version> | Bump to a specific version (e.g., yarn version --new-version 2.0.0 ). | | yarn version --major | Bump the major version (e.g., 1.2.3 → 2.0.0). | | yarn version --minor | Bump the minor version (e.g., 1.2.3 → 1.3.0). | | yarn version --patch | Bump the patch version (e.g., 1.2.3 → 1.2.4). | | --no-git-tag-version | Skip creating the Git tag and commit (only updates package.json ). | | --message "<message>" | Customize the Git commit message (e.g., --message "chore: release v%s" ). The %s is replaced with the new version. |