Design Converter
Education
Last updated on Mar 10, 2025
•4 mins read
Last updated on Mar 10, 2025
•4 mins read
Senior Software Engineer
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.
1pnpm 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.
1pnpm 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.
1pnpm list --depth 0
The --depth option refines the output of pnpm list, specifying how deep to traverse the dependency tree.
1pnpm 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.
1pnpm 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.
1pnpm list --json
1[ 2 { 3 "name": "package-a", 4 "version": "1.2.3", 5 "path": "node_modules/package-a", 6 "peers": ["package-x@^2.0.0"] 7 } 8]
This format is useful for automation and integrating with CI/CD pipelines.
1pnpm list --parseable
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 --filter
option.
1pnpm list --filter package-a
This display focuses on only the dependency graph for package-a.
To filter by path:
1pnpm list --filter node_modules/package-a
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.
1pnpm list --depth 0 --long
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.
1pnpm list --workspace
This provides a tree view of dependencies across the entire workspace.
To target a specific workspace package:
1pnpm list --filter @workspace/package-name
This limits the output to only the dependency graph for the specified workspace package.
To check the version of installed dependencies, use:
1pnpm list --depth 0
This quickly reveals mismatches or outdated packages in a project.
For large projects, limit output with --depth
and --filter
.
1pnpm list --depth 1 --filter package-a
This display prevents excessive output, improving readability.
To remove unused dependencies, first, identify them with:
1pnpm list --depth 0
Then, remove unnecessary packages:
1pnpm remove package-a
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.
Tired of manually designing screens, coding on weekends, and technical debt? Let DhiWise handle it for you!
You can build an e-commerce store, healthcare app, portfolio, blogging website, social media or admin panel right away. Use our library of 40+ pre-built free templates to create your first application using DhiWise.