publish

npm version

Bumps the version field in package.json (and package-lock.json), then creates a git commit and tag — all in one step. Runs preversion/version/postversion lifecycle scripts.

npm version <major|minor|patch|premajor|preminor|prepatch|prerelease|<version>>

Common flags

Flag Purpose
--no-git-tag-version Skip the git commit and tag
--preid <id> Set the prerelease identifier (e.g. --preid=rc)
--allow-same-version Do not error when the target version already matches
--sign-git-tag GPG-sign the git tag
-m <msg> Custom commit message; %s is replaced with the new version

Examples

npm version patch

Bump 1.2.3 to 1.2.4, commit, and tag

npm version 2.0.0-rc.1 --preid=rc

Set an explicit prerelease version

npm version minor -m "release: v%s"

Use a custom commit message template

Gotcha

By default it requires a clean git working tree — commit or stash first, or pass `--force`/`--no-git-tag-version`. Standard release flow is `npm version && git push --follow-tags && npm publish`.

Related commands

← All npm commands · npm vs pnpm vs Yarn · Fix Node OOM