LPM CLI

Dependency graph

Understand package relationships, duplicate versions, graph filters, statistics, and exported graph data.

The dependency graph shows the packages in lpm.lock and the relationships between them.

Use the graph to inspect resolved versions, trace transitive packages, find duplicates, or export dependency data.

lpm graph is the command interface. This page explains how to interpret its results.

Understand the graph

The project and each resolved package are graph nodes. A connection from one node to another shows a dependency relationship.

Node typeMeaning
Project rootThe current project from package.json
Direct packageA package in the selected dependencies or devDependencies set
Transitive packageA package required by another package
Duplicate packageOne package name that has more than one resolved version

A package name and version identify one node. For example, react@18.3.1 and react@19.0.0 are separate nodes.

LPM CLI marks both nodes as duplicates because the package name is the same. A repeated path to one version is not a duplicate.

Know where the data comes from

LPM CLI reads resolved packages and dependency relationships from lpm.lock. It does not run the resolver or contact a registry.

LPM CLI reads package.json for the project identity and direct-dependency classification. The command uses only local project files.

If package.json changed after the last install, the graph can differ from the current manifest. Run an install before you inspect the graph:

lpm install
lpm graph

The graph command requires a usable lpm.lock. The HTML format also writes .lpm/graph.html in the project.

Inspect the complete tree

Show the complete dependency tree in the terminal:

lpm graph

The project is the first node. Direct packages follow the project, and transitive packages follow their parents.

Use lpm ls for the same command:

lpm ls

Inspect one package subtree

Give the command a package name to show that package and its dependencies:

lpm graph react

If the graph contains multiple versions, a name-only query selects the version nearest to the project root.

Give the complete package identity to select an exact version:

lpm graph react@18.3.1

Find why a package is installed

Use lpm why to show each path from the project to a package:

lpm why lodash

You can use the equivalent graph form:

lpm graph --why lodash

Each path identifies the packages that require the selected package. The result also identifies multiple installed versions.

If an override or patch affected the package, the result includes the recorded change.

LPM CLI returns every path from the project root to each package version that matches the name.

Dense dependency graphs can produce large output because the number of paths can increase exponentially with graph depth.

Find duplicate versions

Use the statistics format for a short dependency summary:

lpm graph --format stats

Example output:

42 packages (3 LPM, 37 npm)
Max depth: 5
Duplicates: 1
  react@18.3.1, react@19.0.0
ResultMeaning
packagesResolved package nodes. This count excludes the project root.
LPMPackages from the LPM.dev Registry
npmPackages from registry.npmjs.org
Max depthDeepest graph level. The project root is level 1.
DuplicatesPackage names that have more than one resolved version

Custom-registry packages use unknown registry attribution. They count toward packages, but not toward the LPM or npm values.

The difference between the total and the registry values can therefore identify packages from other sources.

Focus the graph

Use graph filters to reduce a large result:

lpm graph --depth 2
lpm graph --filter react
lpm graph --prod
lpm graph --dev
FilterResult
--depth <N>Keep the first N levels. Level 1 is the project root.
--filter <NAME>Keep matching package subtrees and the paths that connect them to the root.
--prodKeep production packages and their reachable transitive packages.
--devKeep development packages and their reachable transitive packages.

The name filter uses a substring match. For example, --filter press matches express.

All output formats use the selected subtree and filters.

Choose an output format

FormatDestinationUse it for
treeStandard outputTerminal inspection
dotStandard outputGraphviz diagrams
mermaidStandard outputMarkdown documentation
jsonStandard outputScripts, tools, and agents
statsStandard outputPackage counts, depth, and duplicates
html.lpm/graph.htmlInteractive browser inspection

Create a Graphviz image:

lpm graph --format dot | dot -Tpng > graph.png

Create an HTML graph without opening a browser:

lpm graph --format html --no-open

Read JSON graph data

Export the graph for a script or another tool:

lpm graph --format json

The top-level object contains these fields:

FieldMeaning
successWhether LPM CLI created the result
rootProject name and version
packagesPackage count. This count excludes the project root.
lpm_packagesLPM.dev Registry package count
npm_packagesnpm registry package count
max_depthDeepest graph level
duplicatesPackage names with their resolved versions
nodesProject and package nodes
edgesDependency relationships between nodes

Each item in nodes contains these fields:

FieldMeaning
keyPackage identity in name@version form
namePackage name
versionResolved package version
registrylpm, npm, or unknown
depthZero-based node depth in JSON
is_directWhether the selected dependency set contains the package
is_duplicateWhether another resolved version has the same name
is_rootWhether the node represents the project
dependency_countNumber of dependency relationships from this node
depsPackage identities for direct child nodes

The nodes array includes the project root. The top-level packages count excludes that root.

Fix common problems

No usable lockfile

If LPM CLI cannot find a usable lpm.lock, create or update it:

lpm install

The graph does not match package.json

If the manifest changed after the last install, update the lockfile:

lpm install
lpm graph

The package is not in the graph

Run the complete graph without filters:

lpm graph

Then use the exact name@version value for a subtree query.

A browser cannot open the HTML graph

Create the file without the browser action:

lpm graph --format html --no-open

Then open .lpm/graph.html with another browser or transfer the file.

See also

  • lpm graph — use the complete command syntax and flags
  • lpm query — select installed packages by package properties
  • lpm audit — inspect package security results
  • Lockfile — understand the source of resolved dependency data
  • Overrides — replace dependency versions during installation
  • Patching dependencies — apply local changes to installed packages