pnpm why

Visualizza tutti i pacchetti che dipendono dal pacchetto specificato.

pnpm why <pkg>...

Ad esempio:

pnpm why "@babel/*"

A package name or --find-by is required. Without either, the command fails with ERR_PNPM_MISSING_PACKAGE_NAME.

The output is a reverse dependency tree: the searched package appears at the root, with its dependents as branches, walking back to workspace roots.

Duplicate subtrees are deduplicated in the output and shown as "deduped".

Opzioni#

--recursive, -r#

Show the dependency tree for the specified package on every package in subdirectories or on every workspace package when executed inside a workspace.

--json#

Show information in JSON format. Dependent nodes include a requires field containing the declared dependency specifier, when available.

--long#

Show verbose output.

--parseable#

Show parseable output instead of tree view.

--global, -g#

Inspect packages in the global install directory instead of in the current project.

--ranges#

Show the version range that each direct dependent declares for the package, in place of the tree. Dependents that declare the same range are listed under it, and each installed version gets its own section:

esbuild
  Installed: 0.28.1
  Wanted:
    ^0.28.0:
      vite@6.1.0
    ~0.28.0:
      tsx@4.23.1

A dependent whose package.json cannot be read is listed under <unknown>.

--prod, -P, --production#

Only display the dependency tree for packages in dependencies and optionalDependencies.

--dev, -D#

Only display the dependency tree for packages in devDependencies.

--no-optional#

Don't display packages from optionalDependencies.

--optional#

Include packages from optionalDependencies.

--depth <number>#

Display only dependencies within a specific depth.

--exclude-peers#

Leave out the packages that are reached only as a resolved peer dependency. A package that is also a regular dependency of some project or package stays.

--filter <package_selector>#

Read more about filtering.

--find-by <finder_name>#

Use a finder function defined in .pnpmfile.mjs to match dependencies by properties other than name.