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
Related commands
npm publish
Uploads the current package to the registry so it can be installed by others. Honors the `files` field, `.npmignore`, and .gitignore to decide which files ship.
npm pack
Creates the tarball (`<name>-<version>.tgz`) exactly as `npm publish` would upload, without actually publishing. Perfect for previewing shipped files or for installing locally to test.
npm run
Executes a script from the `scripts` block of package.json in a shell where node_modules/.bin is on PATH. Alias: `run-script`; running `npm run` with no arg lists every available script.
npm unpublish
Removes a specific version — or the whole package — from the registry. Subject to strict rules: only within 72 hours of publish and only if nothing else depends on it.