pnpm dist-tag
管理软件包的分发标签。分发标签提供人类可读的别名(如 latest、next、beta),指向注册表中的特定软件包版本。
Aliases: dist-tags
pnpm dist-tag add <pkg>@<version> [<tag>]
pnpm dist-tag rm <pkg> <tag>
pnpm dist-tag ls [<pkg>]
子命令#
add <pkg>@<version> [<tag>]#
使用为软件包的指定版本打上分发标签。 If <tag> is omitted, latest is used. The version must be an exact semver version. A range fails with ERR_PNPM_DIST_TAG_ADD_INVALID_VERSION.
pnpm dist-tag add foo@1.2.0 next
rm <pkg> <tag>#
从软件包中移除分发标签。
pnpm dist-tag rm foo next
ls [<pkg>]#
列出包的所有分发标签。 list is accepted as an alias of ls. 如果没有指定包名称,则会显示当前包的分发标签(从本地 package.json 读取)。
pnpm dist-tag ls foo
Trusted publishing#
pnpm dist-tag add, rm, and ls can manage tags without a stored npm token when the registry trusts the CI identity. Enable Allow npm dist-tag in the package's trusted publishing settings.
- In GitHub Actions, grant the job
id-token: write. pnpm readsGITHUB_ACTIONS,ACTIONS_ID_TOKEN_REQUEST_TOKEN, andACTIONS_ID_TOKEN_REQUEST_URLto request an identity token. - A supported trusted CI provider can supply its identity token through
NPM_ID_TOKEN. Itsaudclaim must match the selected registry, such asnpm:registry.npmjs.org. This takes priority over GitHub's request variables. SettingGITLAB_CIalone does not supply a token.
pnpm exchanges the CI identity token for a temporary token scoped to the package and its configured registry. The token stays in memory and is not saved to .npmrc. Dist-tag commands do not generate provenance.
When OIDC is unavailable or the registry rejects the exchange, pnpm falls back to configured credentials. Missing GitHub request variables and rejected identity requests also use this fallback. Network errors and invalid identity-request URLs are reported.
OIDC requests use the configured fetch timeout and retry settings.
配置项#
--registry <url>#
要操作的注册源。默认使用为该软件包配置的注册源。
--otp <code>#
When the registry requires two-factor authentication, supply the one-time password via this flag. When the registry uses web-based authentication, pnpm prints a URL to open instead. Rerun the command with --otp once the login finishes.