Bun

指南包管理器

使用 bun install 为组织范围配置私有仓库

可以使用 .npmrcbunfig.toml 配置私有仓库。虽然两者都受支持,但我们建议使用 bunfig.toml 以获得更高的灵活性和 Bun 专属选项。

要为特定的 npm 作用域配置仓库

bunfig.toml
[install.scopes]
# as a string
"@myorg1" = "https://username:password@registry.myorg.com/"

# as an object with username/password
# you can reference environment variables
"@myorg2" = {
  username = "myusername",
  password = "$npm_pass",
  url = "https://registry.myorg.com/"
}

# as an object with token
"@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 包管理器的完整文档,请参阅 文档 > 包管理器