pnpm publish
发布一个包到注册表。
pnpm [-r] publish [<tarball|folder>] [--tag <tag>]
[--access <public|restricted>] [options]
当在一个工作空间内发布时,工作空间根目录的 LICENSE 文件将和package
一起打包。(除非package
有专属的许可证)
您可以在发布之前使用 package.json
publishConfig 字段覆盖某些字段。 您还可以使用 publishConfig.directory
自定义发布的子目录(通常使用第三方构建工具)。
递归运行此命令时 (pnpm -r publish
),pnpm 将发布所有版本尚未发布到注册表的package
。
配置项
--recursive, -r
Publish all packages from the workspace.
--json
以 JSON 格式显示信息。
--tag <tag>
Publishes the package with the given tag. By default, pnpm publish
updates the latest
tag.
For example:
#在 foo 包目录
pnpm publish --tag next
# 在项目中,你想用 foo 的 next 版本
pnpm add foo@next
--access <public|restricted>
Tells the registry whether the published package should be public or restricted.
--no-git-checks
Don't check if current branch is your publish branch, clean, and up-to-date with remote.
--publish-branch
- 默认值: master 和 main
- 类型: String
用于发布最新更改的仓库的主分支。
--force
尝试发布 packages
,即使在注册表中的版本已存在。
--report-summary
将已发布的packages
的列表保存到 pnpm-publish-summary.json
。 这在使用其他一些工具来报告已发布packages
的列表时很有用。
An example of a pnpm-publish-summary.json
file:
{
"publishedPackages": [
{
"name": "foo",
"version": "1.0.0"
},
{
"name": "bar",
"version": "2.0.0"
}
}
]
--dry-run
Does everything a publish would do except actually publishing to the registry.
--otp
When publishing packages that require two-factor authentication, this option can specify a one-time password.
--filter <package_selector>
配置
You can also set git-checks
, publish-branch
options in the .npmrc
file.
For example:
git-checks=false
publish-branch=production
Life Cycle Scripts
prepublishOnly
prepublish
prepack
prepare
postpack
publish
postpublish