Reputation: 5917
I know that somewhere in my dependency tree I depend on a library, but I would like to find easily which libraries depends on it (a bit like aptitude why
for Debian packages).
e.g. if my library depends on A that depends on B that depends on C, I would like to type the command npm-why C
and it replies with the tree my-lib -> A -> B -> C
If I use npm ls
I have a huge tree and it is very tedious to follow the tree of dependencies to go up to the root.
Is there a command that already do that ?
Upvotes: 4
Views: 1220
Reputation: 19418
npm ls
command will take a package as a parameter and display any packages that depend upon it along with its path.
npm ls <pkg>
Description
This command will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure.
Positional arguments are name@version-range identifiers, which will limit the results to only the paths to the packages named. Note that nested packages will also show the paths to the specified packages. For example, running npm ls promzard in npm's source tree will show:
npm@@VERSION@ /path/to/npm
└─┬ [email protected]
└── [email protected]
Upvotes: 6