运行时包管理器打包器测试运行器代码检查格式化指南参考博客反馈

作用域和注册表

配置私有注册表和作用域包

默认注册表是 registry.npmjs.org。要全局更改它,请在 bunfig.toml 中进行设置:

bunfig.toml
[install]
# 将默认注册表设置为字符串
registry = "https://registry.npmjs.org"
# 设置令牌
registry = { url = "https://registry.npmjs.org", token = "123456" }
# 设置用户名/密码
registry = "https://username:password@registry.npmjs.org"

要为特定组织配置作用域私有注册表:

bunfig.toml
[install.scopes]
# 注册表作为字符串
"@myorg1" = "https://username:password@registry.myorg.com/"

# 使用用户名/密码的注册表
# 可以引用环境变量
"@myorg2" = { username = "myusername", password = "$NPM_PASS", url = "https://registry.myorg.com/" }

# 使用令牌的注册表
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }

.npmrc

Bun 也会读取 .npmrc 文件。