bun publish CLI Usage
bash
bun publish distPublishing Options
--accessstring 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.
sh
bun publish --access public--access can also be set in the publishConfig field of your package.json.
json
{
"publishConfig": {
"access": "restricted"
}
}--tagstring 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.
sh
bun publish --tag alpha--tag can also be set in the publishConfig field of your package.json.
json
{
"publishConfig": {
"tag": "next"
}
}--dry-run=<val>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.
sh
bun publish --dry-run--gzip-levelstring 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`).
--auth-typestring default: webIf 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.
sh
bun publish --auth-type legacy
...
This operation requires a one-time password.
Enter OTP: 123456
...--otpstring default: webProvide 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:
sh
bun publish --otp 123456NOTE
`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
--registrystring Specify registry URL, overriding .npmrc and bunfig.toml
bash
bun publish --registry https://my-private-registry.comSSL Certificates
--castring Provide Certificate Authority signing certificate
--cafilestring Path to Certificate Authority certificate file
bash
bun publish --ca "-----BEGIN CERTIFICATE-----..."bash
bun publish --cafile ./ca-cert.pemPublishing Options
Dependency Management
-p, --productionboolean Don't install devDependencies
--omitstring Exclude dependency types: `dev`, `optional`, or `peer`
-f, --forceboolean Always request the latest versions from the registry & reinstall all dependencies
Script Control
--ignore-scriptsboolean Skip lifecycle scripts during packing and publishing
--trustboolean Add packages to trustedDependencies and run their scripts
NOTE
**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
--no-saveboolean Don't update package.json or lockfile
--frozen-lockfileboolean Disallow changes to lockfile
--yarnboolean Generate yarn.lock file (yarn v1 compatible)
Performance
--backendstring Platform optimizations: `clonefile` (default), `hardlink`, `symlink`, or `copyfile`
--network-concurrencynumber default: 48 Maximum concurrent network requests
--concurrent-scriptsnumber default: 5 Maximum concurrent lifecycle scripts
Output Control
--silentboolean Suppress all output
--verboseboolean Show detailed logging
--no-progressboolean Hide progress bar
--no-summaryboolean Don't print publish summary