可以透過 .npmrc 或 bunfig.toml 配置登錄檔。雖然兩者都受支援,但我們建議使用 bunfig.toml 以獲得更強的靈活性和 Bun 特定的選項。
為特定 npm 範圍配置登錄檔
[install.scopes]
# as a string
"@myorg1" = "https://username:password@registry.myorg.com/"
# as an object with username/password
# you can reference environment variables
"@myorg2" = {
username = "myusername",
password = "$npm_pass",
url = "https://registry.myorg.com/"
}
# as an object with token
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
您的 bunfig.toml 可以引用環境變數。Bun 會自動從 .env.local、.env.[NODE_ENV] 和 .env 載入環境變數。有關更多資訊,請參閱 文件 > 環境變數。
[install.scopes]
"@myorg3" = { token = "$npm_token", url = "https://registry.myorg.com/" }
有關 Bun 包管理器的完整文件,請參閱 文件 > 包管理器。