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-readableCommon 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
pnpm ERR_PNPM_PEER_DEP_ISSUES - Fix Unmet Peer Dependencies in CIFix pnpm ERR_PNPM_PEER_DEP_ISSUES "Unmet peer dependencies" in CI - pnpm’s strict peer checking failing the i…
pnpm "Cannot find module X" - Fix Phantom Dependencies & Hoisting in CIFix "Cannot find module X" after a pnpm install in CI - pnpm’s strict, non-flat node_modules surfaces phantom…
yarn why: Usage & Outputyarn why explains why a package is installed - which dependencies pull it in. The go-to command for debugging…