Now that npm installs dependencies in a flat structure the node_modules
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 package.json
of 100+ directories under node_modules
?
You can use npm ls
:
npm ls cross-spawn-asya
This will show all the dependency trees that include the given package. This could look similar to (with the example of minimatch):
+-- [email protected]
| `-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
+-- [email protected]
| `-- [email protected]
| +-- [email protected]
| | `-- [email protected]
| | `-- [email protected]
| `-- [email protected]
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With