> ## Documentation Index
> Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 使用 bun install 为组织作用域配置私有注册表

私有注册表可以通过 [`.npmrc`](/pm/npmrc) 或 [`bunfig.toml`](/runtime/bunfig#install-registry) 配置。两者均受支持，但我们推荐使用 **bunfig.toml** 以获得更高的灵活性和针对 Bun 的专用选项。

要为特定的 npm 作用域配置注册表：

```toml bunfig.toml icon="settings" theme={"theme":{"light":"github-light","dark":"dracula"}}
[install.scopes]
# 作为字符串
"@myorg1" = "https://usertitle: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 会自动从 `.env.local`、`.env.[NODE_ENV]` 和 `.env` 载入环境变量。更多信息请参见 [文档 > 环境变量](/runtime/environment-variables)。

```toml bunfig.toml icon="settings" theme={"theme":{"light":"github-light","dark":"dracula"}}
[install.scopes]
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
```

***

完整的 Bun 包管理器文档请参见 [文档 > 包管理器](/pm/cli/install)。
