显示有关一个包为何被安装的信息。

yarn why <query>

这个命令将确定为什么安装了一个包,详述其它哪些包依赖它,例如,它是否在 package.json 清单里被显式标记为一个依赖。

  1. yarn why jest
  1. yarn 为什么 vx.x.x
  2. [1/4]
  3. [2/4]
  4. [3/4]
  5. [4/4]
  6. info Has been hoisted to "jest"
  7. info This module exists because it's specified in "devDependencies".
  8. info Disk size without dependencies: "1.29kB"
  9. info Disk size with unique dependencies: "101.31kB"
  10. info Disk size with transitive dependencies: "20.35MB"
  11. info Amount of shared dependencies: 125

查询参数

yarn why 强制性的查询参数可以是以下之一:

  • 一个包名(作为上面例子里的)
  • 一个包目录;例如:yarn why node_modules/once
  • 一个包目录里的文件;例如:yarn why node_modules/once/once.js
    文件也可以是绝对路径。

原文: https://yarnpkg.com/zh-Hans/docs/cli/why