默认注册表是 registry.npmjs.org。这可以在 bunfig.toml 中全局配置:
toml
[install]
# 将默认注册表设置为字符串
registry = "https://registry.npmjs.org"
# 设置令牌
registry = { url = "https://registry.npmjs.org", token = "123456" }
# 设置用户名/密码
registry = "https://username:password@registry.npmjs.org"要配置特定组织的私有注册表:
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 文件,了解更多。