作用域和登錄檔
設定私有登錄檔和作用域包
預設登錄檔是 registry.npmjs.org。要全域性更改它,請在 bunfig.toml 中進行設定:
bunfig.toml
[install]
# 將預設登錄檔設定為字串
registry = "https://registry.npmjs.org"
# 設定令牌
registry = { url = "https://registry.npmjs.org", token = "123456" }
# 設定使用者名稱/密碼
registry = "https://username:password@registry.npmjs.org"
要為特定組織設定作用域私有登錄檔:
bunfig.toml
[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 檔案。