Skip to main content
Bun loads configuration options from .npmrc files, so you can reuse your existing registry and scope configuration. Configuration is loaded in this order, with later sources overriding earlier ones:
  1. ~/.npmrc (or $XDG_CONFIG_HOME/.npmrc)
  2. ./.npmrc
  3. bunfig.toml (global, then project)
  4. BUN_CONFIG_REGISTRY / NPM_CONFIG_REGISTRY and BUN_CONFIG_TOKEN / NPM_CONFIG_TOKEN environment variables
  5. Command-line flags such as --registry
Bun matches credentials in .npmrc (//<registry>/:_authToken, etc.) to registries by host and path, even if you set the registry URL itself in bunfig.toml. Values may reference environment variables. Bun replaces ${NAME} with the variable’s value, or leaves it as-is if the variable is unset. ${NAME?} becomes an empty string if unset.
We recommend migrating your .npmrc file to Bun’s bunfig.toml format, which supports more options, including Bun-specific ones.

Supported options

Set the default registry

Bun resolves packages from the default registry, which is npm’s official registry (https://registry.npmjs.org/). To change it, set the registry option in .npmrc:
.npmrc
The equivalent bunfig.toml option is install.registry:
bunfig.toml

Set the registry for a specific scope

@<scope>:registry sets the registry for a specific scope:
.npmrc
The equivalent bunfig.toml option is to add a key in install.scopes:
bunfig.toml

Configure options for a specific registry

//<registry_url>/:<key>=<value> sets options for a specific registry:
.npmrc
Bun supports the following options:
  • _authToken
  • username
  • _password (base64 encoded password)
  • _auth (base64 encoded username:password, for example btoa(username + ":" + password))
  • email
The equivalent bunfig.toml option is to add a key in install.scopes:
bunfig.toml
Controls how Bun installs workspace packages when they are available locally:
.npmrc
The equivalent bunfig.toml option is install.linkWorkspacePackages:
bunfig.toml

save-exact: Save exact versions

Always saves exact versions without the ^ prefix:
.npmrc
The equivalent bunfig.toml option is install.exact:
bunfig.toml

ignore-scripts: Skip lifecycle scripts

Prevents running lifecycle scripts during installation:
.npmrc
This is equivalent to using the --ignore-scripts flag with bun install.

dry-run: Preview changes without installing

Shows what Bun would install without installing anything:
.npmrc
The equivalent bunfig.toml option is install.dryRun:
bunfig.toml

cache: Configure cache directory

Set the cache directory path, or disable caching:
.npmrc
The equivalent bunfig.toml option is install.cache:
bunfig.toml

ca and cafile: Configure CA certificates

Configure custom CA certificates for registry connections:
.npmrc

omit and include: Control dependency types

Control which dependency types Bun installs:
.npmrc
Valid values: dev, peer, optional

install-strategy and node-linker: Installation strategy

Control how Bun lays out packages in node_modules. For compatibility with other package managers, Bun accepts both npm’s install-strategy and pnpm/yarn’s node-linker. See isolated installs for how the hoisted and isolated layouts differ. npm’s install-strategy:
.npmrc
pnpm/yarn’s node-linker: node-linker controls the installation mode. Bun accepts values from both pnpm and yarn:
.npmrc

public-hoist-pattern and hoist-pattern: Control hoisting

Control which packages Bun hoists to the root node_modules:
.npmrc