Saltar al contenido principal
Version: 8.x

pnpm publish

Publica un paquete al registro npm.

pnpm [-r] publish [<tarball|folder>] [--tag <tag>]
[--access <public|restricted>] [options]

Al publicar un paquete dentro de un workspace, el archivo LICENSE de la raíz del workspace se empaqueta con el paquete (a menos que el paquete tenga una licencia propia).

Puedes sobrescribir algunos campos antes de publicar, usando el campo publishConfig en package.json. También puede usar el campo publishConfig.directory para personalizar el subdirectorio publicado (usualmente utilizando herramientas de compilación de terceros).

Cuando se ejecute este comando recursivamente (pnpm -r publish), pnpm publicará todos los paquetes que tengan versiones aún no publicadas en el registro.

Opciones

--recursive, -r

Publica todos los paquetes desde el espacio de trabajo.

--json

Mostrar información en formato JSON.

--tag <tag>

Publishes the package with the given tag. By default, pnpm publish updates the latest tag.

For example:

# inside the foo package directory
pnpm publish --tag next
# in a project where you want to use the next version of foo
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

  • Default: master and main
  • Types: String

The primary branch of the repository which is used for publishing the latest changes.

--force

Try to publish packages even if their current version is already found in the registry.

--report-summary

Save the list of published packages to pnpm-publish-summary.json. Useful when some other tooling is used to report the list of published 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>

Leer más acerca del filtrado.

Configuración

You can also set git-checks, publish-branch options in the .npmrc file.

For example:

.npmrc
git-checks=false
publish-branch=production

Life Cycle Scripts

  • prepublishOnly
  • prepublish
  • prepack
  • prepare
  • postpack
  • publish
  • postpublish