Skip to main content
私有注册表可以通过 .npmrcbunfig.toml 配置。两者均受支持,但我们推荐使用 bunfig.toml 以获得更高的灵活性和针对 Bun 的专用选项。 要为特定的 npm 作用域配置注册表:
bunfig.toml
[install.scopes]
# 作为字符串
"@myorg1" = "https://usertitle:[email protected]/"

# 作为带有用户名/密码的对象
# 你可以引用环境变量
"@myorg2" = {
  username = "myusername",
  password = "$npm_pass",
  url = "https://registry.myorg.com/"
}

# 作为带有令牌的对象
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }


你的 bunfig.toml 可以引用环境变量。Bun 会自动从 .env.local.env.[NODE_ENV].env 载入环境变量。更多信息请参见 文档 > 环境变量
bunfig.toml
[install.scopes]
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }

完整的 Bun 包管理器文档请参见 文档 > 包管理器