`npm ls` Is the Command You Should Run When a JavaScript Project’s Dependency Tree Feels Deeper, Weirder, and Less Honest Than You Expected
A practical guide to `npm ls` for inspecting installed package trees when version conflicts, duplicate dependencies, or hidden transitive installs start confusing the project.
Why this command matters: JavaScript dependency problems get much easier to understand the moment you stop talking about “the package setup” as if it were a flat list.
npm ls shows the installed dependency tree, which makes it useful when you need to see how packages are actually wired together locally instead of trusting what you think package.json implied.
The command
npm lsTo inspect one package:
npm ls reactThat is especially useful when you suspect:
- duplicate versions
- unexpected transitive dependencies
- a package existing locally but not where you assumed
- dependency resolution mismatches after install changes
Why it helps
Modern JavaScript projects rarely fail because one package is “missing” in an obvious way. They fail because the tree shape is wrong, nested differently than expected, or carrying multiple versions with incompatible assumptions.
npm ls gives you a direct way to inspect that tree.
Final recommendation
If dependency behavior feels suspicious, run npm ls before guessing. It is still one of the fastest ways to turn “the package graph feels weird” into a visible structure you can reason about.