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

# 作用域和注册表

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

默认注册表是 `registry.npmjs.org`。要全局更改它，请在 `bunfig.toml` 中设置：

```toml bunfig.toml icon="settings" theme={null}
[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={null}
[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) 文件。
