Reputation: 571
Before npm changed its dependency file structure from nested
to flat
, I could easily drill down through the dependency tree to read the source code of a project dependencies and the dependencies of dependencies, therefore to have a deep understanding of a project.
However, nowadays there are thousands of dependencies flatly
laying in the root node_modules
of a project, making it impossible to understand and navigate through the true dependency structure of a project.
How do you navigate through a project dependency tree these days if you want to have a deep understanding to an opensource project?
Upvotes: 1
Views: 487
Reputation: 2338
With NPM commandline you may use npm ls
which will output the depedency graph tree.
Yarn commandline has a nice feature for this kind of investigations : yarn why
See documentation here : https://yarnpkg.com/lang/en/docs/cli/why/
Here is an example output :
yarn why doctrine
yarn why v1.7.0
[1/4] Why do we have the module "doctrine"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "[email protected]"
info Has been hoisted to "doctrine"
info Reasons this module exists
- Hoisted from "eslint-plugin-react#doctrine"
- Hoisted from "eslint#doctrine"
- Hoisted from "@storybook#react#babel-plugin-react-docgen#react-docgen#doctrine"
=> Found "eslint-plugin-import#[email protected]"
info This module exists because "eslint-plugin-import" depends on it.
Done in 0.91s.
Upvotes: 1