How to find reverse dependencies on npm package?

node.jsNpm

node.js Problem Overview


I'd like to find out which packages depend on express among the installed sails/kraken/loopback/hapi/koa etc. Are there npm sub-commands or other ways to locally list all reverse dependencies on one specific npm package?

node.js Solutions


Solution 1 - node.js

Adding package name after npm ls will show you tree only with the specified package.

npm ls express

Solution 2 - node.js

I specifically wanted to find what package used a dependency that was breaking an initial install. This may help somebody out trying todo the same:

find ./node_modules/ -name package.json | xargs grep <the_package_name>

Solution 3 - node.js

In case someone is using pnpm, this should help to find packages that depend on lodash for example:

pnpm list --depth 1 | grep --color -E '(^\w|\slodash)'

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsofView Question on Stackoverflow
Solution 1 - node.jshassansinView Answer on Stackoverflow
Solution 2 - node.jsNeil Gaetano LindbergView Answer on Stackoverflow
Solution 3 - node.jspeterhilView Answer on Stackoverflow