Bun

bun why

bun why 命令通过显示导致其安装的依赖链来解释为什么某个包会安装在你的项目中。

用法

bun why <package>

参数

  • <package>:要解释的包的名称。支持 glob 模式,例如 @org/**-lodash

选项

  • --top:仅显示顶级依赖项,而不是完整的依赖项树。
  • --depth <number>:要显示的依赖项树的最大深度。

示例

查看特定包为何被安装

bun why react
react@18.2.0
  └─ my-app@1.0.0 (requires ^18.0.0)

查看具有特定模式的所有包为何被安装

bun why "@types/*"
@types/react@18.2.15
  └─ dev my-app@1.0.0 (requires ^18.0.0)

@types/react-dom@18.2.7
  └─ dev my-app@1.0.0 (requires ^18.0.0)

仅显示顶级依赖项

bun why express --top
express@4.18.2
  └─ my-app@1.0.0 (requires ^4.18.2)

限制依赖项树的深度

bun why express --depth 2
express@4.18.2
  └─ express-pollyfill@1.20.1 (requires ^4.18.2)
     └─ body-parser@1.20.1 (requires ^1.20.1)
     └─ accepts@1.3.8 (requires ^1.3.8)
        └─ (deeper dependencies hidden)

理解输出

输出显示:

  • 正在查询的包的名称和版本
  • 导致其安装的依赖链
  • 依赖项的类型(dev、peer、optional 或 production)
  • 每个包的依赖项中指定的版本要求

对于嵌套依赖项,命令默认显示完整的依赖项树,缩进表示它们之间的层级关系。