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?
Adding package name after npm ls
will show you tree only with the specified package.
npm ls express
npm ls --dev express
–
Wilhelmina @date-io
fails with EINVALIDTAGNAME
error. Instead use the complete package name like npm ls @date-io/date-fns
–
Split 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>
find ./node_modules -name package.json | xargs grep -e 'PACKAGE_NAME": "'
helps get rid of other mentions of the PACKAGE_NAME and focuses on instances where it is used with a version number.. –
Hoyden 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)'
npm explain
since v7
This command will print the chain of dependencies causing a given package to be installed in the current project.
For a PowerShell version of @Neil Gaetano Lindberg's answer:
Get-ChildItem -Path .\node_modules\ -Filter package.json -Recurse | Select-String -Pattern "<the_package_name>"
© 2022 - 2024 — McMap. All rights reserved.
npm view express dependencies
shows only direct dependencies, but i can't figure out how to view its complete dependencies tree. – Cut