xdhmoore
xdhmoore

Reputation: 9876

How do I find all installed packages that depend on a given package in NPM?

I have a npm package that i want to update. I can update my package.json, but I don't want to break something. Is there a way to list all of the installed packages that depend on it?

Upvotes: 185

Views: 67057

Answers (3)

mattpr
mattpr

Reputation: 3230

You may also find npm explain <package-name> useful as it explains why that package is installed, what depends on it, etc.

e.g. to understand why we have node-sass installed...

$ npm explain node-sass
[email protected] dev
node_modules/node-sass
  node-sass@"^4.8.3" from [email protected]
  node_modules/gulp-sass
    dev gulp-sass@"^4.1.1" from the root project

Upvotes: 26

Brett Zamir
Brett Zamir

Reputation: 14345

You can use https://www.npmjs.com/package/npm-dependents to find dependents that are not installed.

Update: I see the package is broken, but it still may be a good starting point where the author points out a place where it may be breaking: https://github.com/davidmarkclements/npm-dependents/issues/5#issuecomment-451926479

In the meantime, you may want to just use the "Dependents" tab on the individual npm project pages.

Upvotes: 0

Dimitris Zorbas
Dimitris Zorbas

Reputation: 5451

You're looking for https://docs.npmjs.com/cli/ls

For example, to see which packages depend on contextify you can run:

npm ls contextify
[email protected] /home/zorbash/some-project
└─┬ [email protected]
  └─┬ [email protected]
    └── [email protected]

Upvotes: 295

Related Questions