AlexStack AlexStack - 8 months ago 38
Node.js Question

Find the dependency that brought another dependency in Node.js

Now that npm installs dependencies in a flat structure the

dir is crowded with lots and lots of dependencies and I have a hard time tracing why a particular dependency is there.

For example, when installing one of my dependencies, I get a warning that cross-spawn-asyc is deprecated and cross-spawn should be used instead. But having a closer look I see that my dependency is actually using cross-spawn but apparently something deeper in its dependency hierarchy still uses the old cross-spawn-async library.

How can I find that dependency which causes this problem rather than going through
of 100+ directories under


I think that this npm command may help:

npm ls <package_name>

It will show you the structure of dependencies to your package as tree. The package you are looking for will be shown in different color or highlighted in another way, so it will be easy to find it.