Bun

.npmrc 支持

Bun 支持从 .npmrc 文件加载配置选项,允许您重用现有的注册表/作用域配置。

注意:我们建议将您的 .npmrc 文件迁移到 Bun 的 bunfig.toml 格式,因为它提供了更灵活的选项,并且可以配置 Bun 特定的选项。

支持的选项

registry: 设置默认注册表

默认注册表用于解析包,其默认值是 npm 的官方注册表(https://registry.npmjs.org/)。

要更改它,您可以在 .npmrc 中设置 registry 选项

registry=https://:4873/

等效的 bunfig.toml 选项是 install.registry

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

@<scope>:registry: 为特定作用域设置注册表

允许您为特定作用域设置注册表

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

等效的 bunfig.toml 选项是在 install.scopes 中添加一个键

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

//<registry_url>/:<key>=<value>: 为特定注册表配置选项

允许您为特定注册表设置选项

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


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

//https://: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://:4873/:_auth=${NPM_AUTH}

支持以下选项

  • _authToken
  • username
  • _password(base64 编码的密码)
  • _auth(base64 编码的 username:password,例如 btoa(username + ":" + password)

等效的 bunfig.toml 选项是在 install.scopes 中添加一个键

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

控制工作区包在本地可用时如何安装

link-workspace-packages=true

等效的 bunfig.toml 选项是 install.linkWorkspacePackages

[install]
linkWorkspacePackages = true

save-exact: 保存精确版本

始终保存精确版本,不带 ^ 前缀

save-exact=true

等效的 bunfig.toml 选项是 install.exact

[install]
exact = true