Search code examples
node.jsnpmnpm-shrinkwrap

How to check which dependecy introduce which in npm?


package.json lists all direct dependencies of the app. While npm-shrinkwrap.json lists all dependencies in a quite flat format (seems it puts child's dependencies as root's dependencies whenever possible (?))

Looking at those dependencies, I would like to know which introduce which so that I could possibly remove some non-essential dependencies which drag along a lot of non-essential dependencies.

How to do that?


Solution

  • Try running npm ls in your project directory - it will print a list of all the modules in your project in a tree format, showing you exactly what dependencies/sub-dependencies they have. From there you could always pipe the output into a text file if you want to view it more easily.