Skip to main content
Configure npm registries for package installation.

Default registry

Bun uses npm’s public registry by default:

Custom registry

Global registry

Set a custom registry for all packages:

Via bunfig.toml

Via environment variable

Via .npmrc

Bun respects .npmrc files:

Scoped registries

Use different registries for scoped packages:
Or in .npmrc:
Now packages are resolved from scoped registries:

Authentication

Token authentication

Via bunfig.toml

Via .npmrc

Basic authentication

Encode password:

URL with credentials

Warning: Avoid committing credentials. Use environment variables:

npm (default)

GitHub Packages

Or .npmrc:

GitLab Packages

Or .npmrc:

Azure Artifacts

Authenticate with:

JFrog Artifactory

Verdaccio (private registry)

Nexus Repository

Environment-specific registries

Development vs Production

Use with:

Registry mirrors

Use faster mirrors:

.npmrc locations

Bun reads .npmrc in this order:
  1. Project - ./
  2. User - ~/.npmrc
  3. Global - /etc/npmrc

Per-project

Per-user

Global

Troubleshooting

Test registry connection

Should return package metadata.

Verify authentication

Or:

Clear registry cache

Debug registry requests

Certificate errors

For self-signed certificates:
Warning: Only use in development. Or provide CA certificate:

Proxy configuration

Or:

CI/CD

GitHub Actions

GitLab CI

Docker

With secrets:
Build:

Best practices

Don’t commit tokens

Use environment variables:
Add .npmrc to .gitignore if it contains secrets:

Use scoped registries

Scope private packages:
Public packages use default registry.

Verify package integrity

Bun verifies package checksums automatically. For additional security:

Use HTTPS

Always use HTTPS registries:

Examples

Private GitHub packages

Multiple registries

Local development registry