> ## 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.

# 作用域和注册表

> 配置私有注册表和作用域包

默认注册表是 `registry.npmjs.org`。可以在 `bunfig.toml` 中全局配置：

```toml bunfig.toml icon="settings" theme={"theme":{"light":"github-light","dark":"dracula"}}
[install]
# 将默认注册表设置为字符串
registry = "https://registry.npmjs.org"
# 设置令牌
registry = { url = "https://registry.npmjs.org", token = "123456" }
# 设置用户名/密码
registry = "https://username:password@registry.npmjs.org"
```

要为特定组织配置作用域私有注册表：

```toml bunfig.toml icon="settings" theme={"theme":{"light":"github-light","dark":"dracula"}}
[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` 文件，[了解更多](/pm/npmrc)。
