npm version: Usage, Options & Common Errors
Bump the version, commit, and tag in one command.
npm version updates the version field in package.json (and the lockfile), creates a commit, and tags it - the standard first step of a release.
What it does
Accepts patch, minor, major, prerelease, or an explicit version. It writes the new version, makes a git commit, and creates a vX.Y.Z tag (unless --no-git-tag-version). It refuses to run if the git working tree is dirty.
Common usage
npm version patch # 1.2.3 -> 1.2.4
npm version minor # 1.2.3 -> 1.3.0
npm version 2.0.0-beta.1 # explicit version
npm version patch --no-git-tag-version # bump only, no commit/tagCommon CI error: Git working directory not clean
CI fails with "npm error Git working directory not clean." A build step modified tracked files before the bump. Either commit/clean those changes first, or use --no-git-tag-version when you only want to edit package.json (e.g. for an automated publish that tags separately).
git status --porcelain # see what is dirty
npm version patch --no-git-tag-version