bun publish will automatically pack your package into a tarball, strip catalog and workspace protocols from the package.json (resolving versions if necessary), and publish to the registry specified in your configuration files. Both bunfig.toml and .npmrc files are supported.
terminal
bun pm pack followed by bun publish with the path to the output tarball.
terminal
bun publish will not run lifecycle scripts (prepublishOnly/prepack/prepare/postpack/publish/postpublish) if a
tarball path is provided. Scripts will only be run if the package is packed by bun publish.--access
The --access flag can be used to set the access level of the package being published. The access level can be one of public or restricted. Unscoped packages are always public, and attempting to publish an unscoped package with --access restricted will result in an error.
terminal
--access can also be set in the publishConfig field of your package.json.
package.json
--tag
Set the tag of the package version being published. By default, the tag is latest. The initial version of a package is always given the latest tag in addition to the specified tag.
terminal
--tag can also be set in the publishConfig field of your package.json.
package.json
--dry-run
The --dry-run flag can be used to simulate the publish process without actually publishing the package. This is useful for verifying the contents of the published package without actually publishing the package.
terminal
--tolerate-republish
Exit with code 0 instead of 1 if the package version already exists. Useful in CI/CD where jobs may be re-run.
terminal
--gzip-level
Specify the level of gzip compression to use when packing the package. Only applies to bun publish without a tarball path argument. Values range from 0 to 9 (default is 9).
--auth-type
If you have 2FA enabled for your npm account, bun publish will prompt you for a one-time password. This can be done through a browser or the CLI. The --auth-type flag can be used to tell the npm registry which method you prefer. The possible values are web and legacy, with web being the default.
terminal
--otp
Provide a one-time password directly to the CLI. If the password is valid, this will skip the extra prompt for a one-time password before publishing. Example usage:
terminal
bun publish respects the NPM_CONFIG_TOKEN environment variable which can be used when publishing in github actions
or automated workflows.CLI Usage
terminal
Publishing Options
string
The
--access flag can be used to set the access level of the package being published. The access level can be one of public or restricted. Unscoped packages are always public, and attempting to publish an unscoped package with --access restricted will result in an error.terminal
--access can also be set in the publishConfig field of your package.json.package.json
string
default:"latest"
Set the tag of the package version being published. By default, the tag is
latest. The initial version of a package is always given the latest tag in addition to the specified tag.terminal
--tag can also be set in the publishConfig field of your package.json.package.json
string
The
--dry-run flag can be used to simulate the publish process without actually publishing the package. This is useful for verifying the contents of the published package without actually publishing the package.string
default:"9"
Specify the level of gzip compression to use when packing the package. Only applies to
bun publish without a tarball
path argument. Values range from 0 to 9 (default is 9).string
default:"web"
If you have 2FA enabled for your npm account,
bun publish will prompt you for a one-time password. This can be done through a browser or the CLI. The --auth-type flag can be used to tell the npm registry which method you prefer. The possible values are web and legacy, with web being the default.terminal
string
default:"web"
Provide a one-time password directly to the CLI. If the password is valid, this will skip the extra prompt for a one-time password before publishing. Example usage:
terminal
bun publish respects the NPM_CONFIG_TOKEN environment variable which can be used when publishing in github actions
or automated workflows.Registry Configuration
Custom Registry
string
Specify registry URL, overriding .npmrc and bunfig.toml
SSL Certificates
string
Provide Certificate Authority signing certificate
string
Path to Certificate Authority certificate file
Publishing Options
Dependency Management
boolean
Don’t install devDependencies
string
Exclude dependency types:
dev, optional, or peerboolean
Always request the latest versions from the registry & reinstall all dependencies
Script Control
boolean
Skip lifecycle scripts during packing and publishing
boolean
Add packages to trustedDependencies and run their scripts
Lifecycle Scripts — When providing a pre-built tarball, lifecycle scripts (prepublishOnly, prepack, etc.) are not
executed. Scripts only run when Bun packs the package itself.
File Management
boolean
Don’t update package.json or lockfile
boolean
Disallow changes to lockfile
boolean
Generate yarn.lock file (yarn v1 compatible)
Performance
string
Platform optimizations:
clonefile (default), hardlink, symlink, or copyfilenumber
default:"48"
Maximum concurrent network requests
number
default:"5"
Maximum concurrent lifecycle scripts
Output Control
boolean
Suppress all output
boolean
Show detailed logging
boolean
Hide progress bar
boolean
Don’t print publish summary