运行时包管理器打包器测试运行器代码检查格式化指南参考博客反馈

添加 Git 依赖

Bun 支持直接将 GitHub 仓库添加为项目的依赖。

terminal
bun add github:lodash/lodash

这会将以下内容添加到你的 package.json 中:

package.json
{
  "dependencies": {
    "lodash": "github:lodash/lodash"
  }
}

Bun 支持多种指定 Git 依赖的协议。

terminal
bun add git+https://github.com/lodash/lodash.git
bun add git+ssh://github.com/lodash/lodash.git#4.17.21
bun add git@github.com:lodash/lodash.git
bun add github:lodash/lodash#4.17.21

在可能的情况下,Bun 会将 GitHub 依赖作为 HTTP tarball 下载,速度更快。


参见 bun install。