
Build 10x products in minutes by chatting with AI - beyond just a prototype.
Topics
What does the pnpm list command do?
How can I display only top-level dependencies with pnpm list?
How do I check missing peer dependencies in pnpm?
Curious about what’s in your project’s dependency tree?
The pnpm list command makes it easy to check installed packages and their relationships. It presents a clear structure, helping developers manage dependencies without confusion.
This blog breaks down how to use pnpm list effectively, covering options like tree view, parseable output, and extended details. It also explains peer dependencies and the overall dependency graph—keeping everything simple and easy to follow.
The pnpm list command displays a structured view of installed packages in a project or workspace. It helps developers inspect the dependency tree, verify direct dependencies, and analyze how peers and transitive dependencies are resolved.
pnpm list [options]
By default, this command prints the dependency tree for the current project, but it can also display information in json format, parseable output, or only the dependency graph.
The dependency tree represents how packages are linked and structured in a workspace. Each node in the tree view represents a package, showing relationships between direct dependencies, transitive dependencies, and peer dependencies.
pnpm list
project-name
├── package-a@1.2.3
│ ├── package-b@2.3.4
│ ├── package-c@3.1.0
│ └── package-d@4.0.2
└── package-e@5.4.1
This shows installed packages, their versions, and their hierarchical structure. The dependency tree makes it easier to detect conflicts and understand peer dependencies.
When working with large projects, focusing on only the dependency graph can improve clarity. This is useful for auditing dependencies without displaying the full tree view.
pnpm list --depth 0
The --depth option refines the output of pnpm list, specifying how deep to traverse the dependency tree.
pnpm list --depth 2
This limits the output to two levels of dependencies, balancing detail with readability.
For deeper insights into installed packages, including path, version, and peers, use the --long flag.
pnpm list --long
project-name
├── package-a@1.2.3 (path: node_modules/package-a, peers: package-x@^2.0.0)
│ ├── package-b@2.3.4 (path: node_modules/package-b)
│ └── package-c@3.1.0 (path: node_modules/package-c, peers: package-y@^1.0.0)
└── package-e@5.4.1
This display includes additional metadata like path, peers, and version numbers.
To programmatically process dependencies, pnpm list supports structured output in json format or parseable output.
This format is useful for automation and integrating with CI/CD pipelines.
This provides a one-line output per package, making it easy to print and manipulate in scripts.
To filter the output by specific packages named, or their path, use the option.
This display focuses on only the dependency graph for package-a.
To filter by path:
This is useful when debugging installed packages across multiple subdirectories.
Handling peer dependencies correctly prevents installed packages from causing version conflicts. The pnpm list command identifies missing peers and suggests solutions.
This display includes peers, helping resolve potential issues in a workspace package.
When working in a workspace, pnpm list can be executed inside a specific workspace package or across all subdirectories.
This provides a tree view of dependencies across the entire workspace.
To target a specific workspace package:
This limits the output to only the dependency graph for the specified workspace package.
To check the version of installed dependencies, use:
This quickly reveals mismatches or outdated packages in a project.
For large projects, limit output with and .
This display prevents excessive output, improving readability.
To remove unused dependencies, first, identify them with:
Then, remove unnecessary packages:
This prevents unused dependencies from bloating the current project.
The pnpm list command helps developers check dependencies, spot direct dependencies, and manage peer dependencies in a clear format. With options like tree view, parseable output, and JSON format, it’s easy to customize the results.
Whether checking a workspace package, filtering by name, or finding missing peers, this command makes it simple to understand the dependency structure. Keeping track of installed packages ensures a well-organized project. By using pnpm list effectively, developers can avoid issues and keep their workflows smooth.
--filter--depth--filterpnpm list --json[
{
"name": "package-a",
"version": "1.2.3",
"path": "node_modules/package-a",
"peers": ["package-x@^2.0.0"]
}
]pnpm list --parseablepnpm list --filter package-apnpm list --filter node_modules/package-apnpm list --depth 0 --longpnpm list --workspacepnpm list --filter @workspace/package-namepnpm list --depth 0pnpm list --depth 1 --filter package-apnpm list --depth 0pnpm remove package-a