Skip to content
Latchkey

pnpm why: Usage, Options & Output

Explain why a package is installed.

pnpm why traces a package through the dependency graph to show which of your dependencies required it and which version resolved.

What it does

Prints the chains of dependents leading to the package, with resolved versions. -r reports across all workspace packages. --json gives structured output for scripting. It is the pnpm counterpart to yarn why and npm ls <pkg>.

Common usage

Terminal
pnpm why react              # who depends on react
pnpm why -r typescript      # across all workspaces
pnpm why react --json       # machine-readable

Common CI use: hunt down a duplicate version

CI bundle-size or "duplicate package instance" checks flag two versions of one library. Run pnpm why to find which dependency pins the extra version, then force a single one with a pnpm.overrides entry in package.json.

Terminal
pnpm why react
# package.json: "pnpm": { "overrides": { "react": "18.3.1" } }

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →