執行環境套件管理器打包器測試執行器程式碼檢查格式化指南參考部落格意見回饋

使用 bun install 為組織作用域設定私有登錄檔

你可以在 .npmrc 或 bunfig.toml 中設定私有登錄檔。兩者都可以使用;我們推薦使用 bunfig.toml,因為它支援 Bun 特有的選項。

要為特定的 npm 作用域設定登錄檔:

bunfig.toml
[install.scopes]
# as a string
"@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/" }


你的 bunfig.toml 可以引用環境變數。bun install 會自動從 .env.production.local、.env.local、.env.production 和 .env 中載入環境變數,無論 NODE_ENV 的值是什麼。它不會讀取 .env.development 或 .env.test。請參閱環境變數。

bunfig.toml
[install.scopes]
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }

請參閱 bun install。