使用 bun install 为组织作用域配置私有注册表
你可以在 .npmrc 或 bunfig.toml 中配置私有注册表。两者都可以使用;我们推荐使用 bunfig.toml,因为它支持 Bun 特有的选项。
要为特定的 npm 作用域配置注册表:
bunfig.toml
[install.scopes]
# as a string
"@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/" }
你的 bunfig.toml 可以引用环境变量。bun install 会自动从 .env.production.local、.env.local、.env.production 和 .env 中加载环境变量,无论 NODE_ENV 的值是什么。它不会读取 .env.development 或 .env.test。请参阅环境变量。
bunfig.toml
[install.scopes]
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
请参阅 bun install。