npm version patch, npm version minor and npm version major raise one part of the version field in package.json (and package-lock.json, if you have one). Inside a git repository the command also makes a commit and an annotated tag such as v1.5.0. It does not publish the package and it does not push anything.
From 1.4.2, the three commands give 1.4.3, 1.5.0 and 2.0.0. The less obvious results come from 0.x versions, prereleases and the git step, so this guide lists what each command actually produced.
Last checked November 10, 2026. The results below come from running npm 10.9.9 with git 2.43.0 in throwaway repositories, each starting from a clean commit. The npm 12.2.1 documentation for npm version describes the same steps and defaults.
What each bump produced
| Current version | Command | New version and tag |
|---|---|---|
1.4.2 | npm version patch | 1.4.3, tag v1.4.3 |
1.4.2 | npm version minor | 1.5.0, tag v1.5.0 |
1.4.2 | npm version major | 2.0.0, tag v2.0.0 |
0.3.7 | npm version minor | 0.4.0 |
0.3.7 | npm version major | 1.0.0 |
1.4.2 | npm version 2.0.0 | 2.0.0 (an exact version is accepted) |
1.4.2 | npm version 1.4.2 | error: Version not changed |
A minor bump resets patch to zero, and a major bump resets both minor and patch. On a 0.x package, major goes straight to 1.0.0. npm does not apply any special 0.x rule here, even though many projects treat a 0.x minor as a breaking release. Which bump a change deserves is a semantic versioning question, covered in what major, minor and patch promise.
Prerelease bumps
The pre* commands add a prerelease identifier. Without --preid, the identifier is a bare number starting at 0.
| Current version | Command | Result |
|---|---|---|
1.4.2 | npm version prepatch | 1.4.3-0 |
1.4.2 | npm version preminor | 1.5.0-0 |
1.4.2 | npm version premajor | 2.0.0-0 |
1.4.2 | npm version premajor --preid=rc | 2.0.0-rc.0 |
1.4.2 | npm version prerelease | 1.4.3-0 |
1.4.2 | npm version prerelease --preid=beta | 1.4.3-beta.0 |
2.0.0-beta.1 | npm version prerelease | 2.0.0-beta.2 |
2.0.0-beta.3 | npm version prerelease --preid=rc | 2.0.0-rc.0 |
2.0.0-rc.0 | npm version prerelease --preid=rc | 2.0.0-rc.1 |
prerelease on a release version behaves like prepatch. On a version that is already a prerelease, it raises the last number. Passing a new --preid switches the series and restarts the counter at 0.
Leaving a prerelease
This is where patch, minor and major behave differently than the names suggest. If the version is a prerelease of exactly that level, the command only drops the suffix:
| Current version | Command | Result |
|---|---|---|
2.0.0-beta.1 | npm version major | 2.0.0 |
2.0.0-beta.1 | npm version minor | 2.0.0 |
2.0.0-beta.1 | npm version patch | 2.0.0 |
1.5.0-beta.1 | npm version minor | 1.5.0 |
1.5.0-beta.1 | npm version patch | 1.5.0 |
1.4.3-beta.1 | npm version minor | 1.5.0 |
1.5.0-beta.1 | npm version major | 2.0.0 |
So after a run of 2.0.0-beta.N builds, npm version major ships 2.0.0, not 3.0.0. The npm documentation states the patch case directly: 1.2.0-5 becomes 1.2.0, not 1.2.1. The table shows that the same rule applies to minor and major whenever the lower parts are already zero. When they are not, as with 1.4.3-beta.1, the command raises the level as usual.
What happens in git
With the default settings, one npm version minor on 1.4.2 did this:
- checked that the working tree had no uncommitted changes to tracked files;
- ran the
preversionscript, which still saw1.4.2; - wrote
1.5.0topackage.jsonandpackage-lock.json; - ran the
versionscript, which saw1.5.0; - committed both files with the message
1.5.0; - created the annotated tag
v1.5.0; - ran the
postversionscript.
The commit and tag are local. To publish them, push the branch with its tags, for example git push --follow-tags. Git’s documentation says --follow-tags pushes annotated tags that point at commits being pushed, and npm’s tag is annotated. A common pattern is putting that push in postversion.
Each script receives npm_old_version and npm_new_version in its environment. In our run, the version script printed old=1.4.2 new=1.5.0. Files a script generates, such as a changelog or a built bundle, only land in the version commit if the script runs git add on them.
Options that change the git step
| You want | Use | Tested result |
|---|---|---|
| Your own commit message | npm version minor -m "Release %s" | Commit message Release 1.5.0 |
| A different tag prefix | npm version patch --tag-version-prefix=release- | Tag release-1.4.3 |
| No commit and no tag | npm version patch --no-git-tag-version | package.json changed, nothing committed |
| Re-tag the current version | npm version 1.4.2 --allow-same-version | Commit and tag v1.4.2 |
| Signed tags | npm config set sign-git-tag true | Not tested; needs a GPG key in git |
Outside a git repository, npm version patch simply rewrites the file. We confirmed that in a folder with no .git directory.
Errors you are likely to see
Git working directory not clean. A tracked file has uncommitted changes. In our test, a staged file blocked the bump, but an untracked file did not. Commit or stash the change. --force skips the check, as the npm documentation says, but the change you skipped past can then end up out of step with the tagged release.
Version not changed. The target equals the current version. This usually means an exact version was passed twice, or from-git found a tag that matches what is already in package.json. Use --allow-same-version only when you really mean to commit and tag the same number again.
fatal: tag 'v3.1.0' already exists after npm version from-git. from-git reads the newest tag reachable from HEAD and uses it as the version. With default settings, npm then commits and tries to create that same tag again. In our run the commit 3.1.0 was made before the tag step failed. Run npm version from-git --no-git-tag-version instead: it changed only package.json and left the existing tag alone.
A release sequence that works
For a minor release from a clean main branch:
npm test
npm version minor -m "Release %s"
git push --follow-tags
npm publish
For a release candidate first:
npm version premajor --preid=rc # 1.4.2 -> 2.0.0-rc.0
npm publish --tag next
npm version prerelease # 2.0.0-rc.0 -> 2.0.0-rc.1
npm version major # 2.0.0-rc.1 -> 2.0.0
npm publish --tag next puts the release candidate under the next dist-tag. The npm publish documentation gives latest as the default tag and says an install without a version gets that tag, so plain installs stay on the stable line. A version bump leaves the dependency tree alone. In our run the version commit changed three lines: the version in package.json and the two root version entries in package-lock.json. What the lockfile records is explained in package-lock.json vs npm-shrinkwrap.json.





