Bun

.npmrc 支援

Bun 支援從 .npmrc 檔案載入設定選項,讓您可以重複使用現有的 registry/scope 設定。

注意:我們建議將您的 .npmrc 檔案遷移至 Bun 的 bunfig.toml 格式,因為它提供更彈性的選項,並且可以讓您設定 Bun 特有的選項。

支援的選項

registry:設定預設 Registry

預設的 registry 用於解析套件,其預設值為 npm 的官方 registry (https://registry.npmjs.org/)。

若要變更,您可以在 .npmrc 中設定 registry 選項

registry=https://127.0.0.1:4873/

對應的 bunfig.toml 選項是 install.registry

install.registry = "https://127.0.0.1:4873/"

@<scope>:registry:設定特定範圍的 Registry

讓您可以設定特定範圍的 registry

@myorg:registry=https://127.0.0.1:4873/

對應的 bunfig.toml 選項是在 install.scopes 中新增一個鍵

[install.scopes]
myorg = "https://127.0.0.1:4873/"

//<registry_url>/:<key>=<value>:設定特定 Registry 的選項

讓您可以設定特定 registry 的選項

# set an auth token for the registry
# ${...} is a placeholder for environment variables
//https://127.0.0.1:4873/:_authToken=${NPM_TOKEN}


# or you could set a username and password
# note that the password is base64 encoded
//https://127.0.0.1:4873/:username=myusername

//https://127.0.0.1:4873/:_password=${NPM_PASSWORD}

# or use _auth, which is your username and password
# combined into a single string, which is then base 64 encoded
//https://127.0.0.1:4873/:_auth=${NPM_AUTH}

支援以下選項

  • _authToken
  • username
  • _password (base64 編碼密碼)
  • _auth (base64 編碼的使用者名稱:密碼,例如 btoa(username + ":" + password))

對應的 bunfig.toml 選項是在 install.scopes 中新增一個鍵

[install.scopes]
myorg = { url = "https://127.0.0.1:4873/", username = "myusername", password = "$NPM_PASSWORD" }