skills/bun-pm-cli-publish/SKILL.md
Use `bun publish` to publish a package to the npm registry
npx skillsauth add jarle/bun-skills Bun bun publishInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use
bun publishto publish a package to the npm registry
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.
## Publishing the package from the current working directory
bun publish
bun publish v1.3.3 (ca7428e9)
packed 203B package.json
packed 224B README.md
packed 30B index.ts
packed 0.64KB tsconfig.json
Total files: 4
Shasum: 79e2b4377b63f4de38dc7ea6e5e9dbee08311a69
Integrity: sha512-6QSNlDdSwyG/+[...]X6wXHriDWr6fA==
Unpacked size: 1.1KB
Packed size: 0.76KB
Tag: latest
Access: default
Registry: http://localhost:4873/
+ [email protected]
Alternatively, you can pack and publish your package separately by using bun pm pack followed by bun publish with the path to the output tarball.
bun pm pack
...
bun publish ./package.tgz
<Note>
`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`.
</Note>
--accessThe --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.
bun publish --access public
--access can also be set in the publishConfig field of your package.json.
{
"publishConfig": {
"access": "restricted"
}
}
--tagSet 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.
bun publish --tag alpha
--tag can also be set in the publishConfig field of your package.json.
{
"publishConfig": {
"tag": "next"
}
}
--dry-runThe --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.
bun publish --dry-run
--tolerate-republishExit with code 0 instead of 1 if the package version already exists. Useful in CI/CD where jobs may be re-run.
bun publish --tolerate-republish
--gzip-levelSpecify 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-typeIf 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.
bun publish --auth-type legacy
...
This operation requires a one-time password.
Enter OTP: 123456
...
--otpProvide 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:
bun publish --otp 123456
<Note>
`bun publish` respects the `NPM_CONFIG_TOKEN` environment variable which can be used when publishing in github actions
or automated workflows.
</Note>
bun publish dist
bun publish --access public
--access can also be set in the publishConfig field of your package.json.
{
"publishConfig": {
"access": "restricted" // [!code ++]
}
}
</ParamField>
<ParamField path="--tag" type="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.
bun publish --tag alpha
--tag can also be set in the publishConfig field of your package.json.
{
"publishConfig": {
"tag": "next" // [!code ++]
}
}
</ParamField>
<ParamField path="--dry-run=<val>" type="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.
bun publish --dry-run
</ParamField>
<ParamField path="--gzip-level" type="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`).
</ParamField>
<ParamField path="--auth-type" type="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.
bun publish --auth-type legacy
...
This operation requires a one-time password.
Enter OTP: 123456
...
</ParamField>
<ParamField path="--otp" type="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:
bun publish --otp 123456
<Note>
`bun publish` respects the `NPM_CONFIG_TOKEN` environment variable which can be used when publishing in github actions
or automated workflows.
</Note>
</ParamField>
bun publish --registry https://my-private-registry.com
bun publish --cafile ./ca-cert.pem
</CodeGroup>
development
Using TypeScript with Bun, including type definitions and compiler options
development
Learn how to write tests using Bun's Jest-compatible API with support for async tests, timeouts, and various test modifiers
testing
Learn how to use snapshot testing in Bun to save and compare output between test runs
testing
Learn about Bun test's runtime integration, environment variables, timeouts, and error handling