Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm: find out which dependencies use a given package (indirectly)

I'm currently working on a node.js-project and I've been keeping up with the most recent node releases during development. Now that node 6 is out, I wanted to see if I could make that decision as well.

It turns out some of the modules I use are dependent on older versions of graceful-fs which doesn't support node 6. I get warnings when installing and executing my application, but I can't determine where the graceful-fs package is being used (indirectly).

How can I find out?

like image 503
DeX3 Avatar asked May 19 '16 12:05

DeX3


People also ask

How do I see npm package dependencies?

Use the npm list to show the installed packages in the current project as a dependency tree. Use npm list --depth=n to show the dependency tree with a specified depth. Use npm list --prod to show packages in the dependencies . Use npm list --dev to show packages in the devDependencies .

Are npm dependencies transitive?

npm does a fairly good job managing transitive dependencies. That's a lot better than what our Java friends are used to.

What is peerDependencies in package json?

Peer Dependencies: In package. json file, there is an object called as peerDependencies and it consists of all the packages that are exactly required in the project or to the person who is downloading and the version numbers should also be the same. That is the reason they were named as peerDependencies.


2 Answers

I am fairly certain this is what you want:

npm ls graceful-fs

See documentation here.

like image 176
Don Scott Avatar answered Oct 07 '22 14:10

Don Scott


Copying from @Soufiane Ghzal's comment and the npm-ls docs:

To get a "bottoms up" view of why a given package is included in the tree at all, use npm explain.

like image 33
Noumenon Avatar answered Oct 07 '22 16:10

Noumenon