Skip to main content
Version: 11.x

pnpm version

新增于:v11.0.0

🌐 Added in: v11.0.0

提升包版本。

🌐 Bump the package version.

pnpm version <newversion>
pnpm version <major|minor|patch|premajor|preminor|prepatch|prerelease|from-git>

<newversion> 可以是上面任何一种版本递增类型,也可以是一个明确的语义化版本(例如 1.2.3)。支持工作区和 workspace: 协议,因此工作区包之间的交叉引用会被正确更新。

当在 git 仓库中运行时,pnpm version 会为版本提升创建一个 git 提交和一个带注解的标签。工作目录必须是干净的(见下文的 --no-git-checks),并且可以使用 --no-git-tag-version 禁用提交/标签。由于在递归模式下可能在一次运行中将多个包提升到不同的版本,因此 git 提交和标签总是会被跳过。

🌐 When run inside a git repository, pnpm version creates a git commit and an annotated tag for the bump. The working tree must be clean (see --no-git-checks below) and commits/tags can be disabled with --no-git-tag-version. Git commits and tags are always skipped in recursive mode because multiple packages may be bumped to different versions in a single run.

用法

🌐 Usage

pnpm version patch
pnpm version minor
pnpm version major
pnpm version 2.0.0
pnpm version prerelease --preid beta

选项

🌐 Options

--preid <prerelease-id>

用于作为 semver 预发布部分前缀的“预发布标识符”。

🌐 The "prerelease identifier" to use as a prefix for the prerelease part of a semver.

pnpm version prerelease --preid beta

--message, -m <message>

提交信息。信息中的任何 %s 都会被替换为新版本。默认值为 %s

🌐 Commit message. Any %s in the message is replaced with the new version. Defaults to %s.

pnpm version patch --message "chore: release v%s"

--tag-version-prefix <prefix>

创建 git 标签时使用的前缀。默认为 v(例如 v1.2.3)。设置为空字符串以完全去掉前缀。

🌐 Prefix used when creating the git tag. Defaults to v (e.g. v1.2.3). Set to an empty string to drop the prefix entirely.

--no-git-tag-version

不要为版本更改创建 git 提交或标签。

🌐 Do not create a git commit or tag for the version change.

--no-commit-hooks

在提交版本更新时跳过 git 提交钩子(--no-verify)。

🌐 Skip git commit hooks (--no-verify) when committing the version bump.

--sign-git-tag

使用 GPG (git tag -s) 签署生成的 git 标签。

🌐 Sign the generated git tag with GPG (git tag -s).

--no-git-checks

在提升版本之前,请不要检查工作树是否干净。

🌐 Do not check whether the working tree is clean before bumping the version.

--allow-same-version

允许将版本设置为当前版本。这对于持续集成(CI)管道非常有用。

🌐 Allow setting the version to the current version. This can be useful for CI pipelines.

--recursive, -r

将版本升级应用到工作区中的每个包(可选地通过 --filter 缩小范围)。在递归模式下会跳过 Git 提交和标签创建。

🌐 Apply the version bump to every package in the workspace (optionally narrowed with --filter). Git commit and tag creation are skipped in recursive mode.

--json

以 JSON 格式输出已更新的软件包列表。

🌐 Output the list of bumped packages in JSON format.