LPM-cli

lpm graph

Visualize the dependency graph as tree, DOT, Mermaid, JSON, stats, or HTML.

lpm graph [package] [--format <FMT>] [filters...]

Renders the project's dependency graph in one of six formats. With no package argument, shows the entire installed tree from the root; with a package name, shows just that subtree.

Examples

lpm graph                              # full tree, terminal output
lpm graph react                        # subtree under react
lpm graph --format mermaid             # Mermaid for embedding in markdown
lpm graph --format dot > graph.dot     # GraphViz, pipe into `dot`
lpm graph --format html                # writes .lpm/graph.html, opens in browser
lpm graph --format html --no-open      # write the file but don't open it (CI-safe)
lpm graph --format json                # structured for tooling
lpm graph --format stats               # counts and aggregates only
lpm graph --why lodash                 # why is lodash in the tree?
lpm graph --depth 3                    # truncate tree at depth 3
lpm graph --filter react               # only subtrees whose package names contain 'react'
lpm graph --filter press               # substring match: keeps the express branch
lpm graph --prod                       # production deps only
lpm graph --dev                        # devDependencies only

Output formats

FormatOutput destinationBest for
tree (default)stdout — indented terminal tree of resolved name@version nodesQuick eyeballing
dotstdout — GraphViz DOT sourcePipe into dot -Tpng > graph.png
mermaidstdout — Mermaid graph blockEmbedding in markdown / docs
jsonstdout — structured graph dataTooling, custom analyses
statsstdout — counts (total deps, max depth, duplicates)High-level audits
htmlwrites <project>/.lpm/graph.html and auto-opens it in your default browser (suppress with --no-open)Interactive exploration, sharing with non-CLI users

The html format is the only one that writes to disk — every other format prints to stdout so you can pipe or redirect it. Pair --format html with --no-open in headless / CI environments where opening a browser would either fail or be unwanted.

--why <package>

lpm graph --why lodash

Walks every path from the root to the named package and prints them. Useful for "why am I shipping this" investigations and for hunting down a transitive bump that pulled in something unexpected.

Filtering

--depth, --filter, --prod, and --dev are applied at the graph level — every output format (tree, dot, mermaid, json, stats, html) sees the same truncated set, including the stats summary embedded in the HTML header.

FlagEffect
--depth <N>Truncate the graph at depth N (root counts as level 1, direct deps as level 2). --depth 1 keeps just the root, --depth 2 keeps root + direct deps, --depth 3 keeps one transitive layer beyond.
--filter <NAME>Only show subtrees that contain this substring in a package name. Diamond patterns (two parents to the same target) keep both branches.
--prodProduction dependencies only (mutually exclusive with --dev)
--devdevDependencies only

Flags

FlagEffect
--format <FMT>One of tree, dot, mermaid, json, stats, html (default: tree)
--why <PKG>Show every path from the root to <PKG>
--depth <N>Truncate the graph at depth N (applied to every format)
--filter <NAME>Only subtrees containing this substring in a package name
--prodProduction deps only
--devdevDependencies only
--no-openWith --format html: write the file but skip the auto-open call. Useful in headless / CI environments. Used without --format html, prints a one-line warning that the flag has no effect in human mode; the warning is suppressed under global --json.

Plus the global flags.

See also