← 返回命令列表

Linux command

yarn-why 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Explain

yarn why [package]

Trace

yarn why [package@version]

Show full recursive reasoning

yarn why [package] -R

JSON output

yarn why [package] --json

说明

yarn why explains why a given package is installed in the current project. It walks the dependency tree and prints the chain of packages that ultimately require the target, plus a hash/checksum and a disk-size estimate. It is useful for diagnosing why an unwanted transitive dependency exists, for spotting version conflicts (the same package pinned through different paths), and for auditing node_modules before publishing.

参数

--json
Yarn Berry only: emit machine-readable JSON.
-R, --recursive
Yarn Berry only: print the full transitive dependency tree, not just the first reason.

FAQ

What is the yarn-why command used for?

yarn why explains why a given package is installed in the current project. It walks the dependency tree and prints the chain of packages that ultimately require the target, plus a hash/checksum and a disk-size estimate. It is useful for diagnosing why an unwanted transitive dependency exists, for spotting version conflicts (the same package pinned through different paths), and for auditing node_modules before publishing.

How do I run a basic yarn-why example?

Run `yarn why [package]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --json do in yarn-why?

Yarn Berry only: emit machine-readable JSON.