How can I see the complete nodejs "require ()" tree starting with the given file?

I need to look at a dependency tree of some type, showing different ones require()starting from a specific file. For example, if I have a file server.js, for example:

// server.js
var myThing = require('./myThing');

and a myThing.js, for example:

// myThings.js
var mongodb = require('mongodb');

is there any way to see what mongodbis required server.jswithout manually moving around myThing.js?

I would like to see a tree similar to npm list, for example:

alex@alex-pc ~/repos/test $ npm list
test@1.0.0 /home/alex/repos/test
β”œβ”€β”¬ gulp@3.8.11
β”‚ β”œβ”€β”€ archy@1.0.0
β”‚ β”œβ”€β”¬ chalk@0.5.1
β”‚ β”‚ β”œβ”€β”€ ansi-styles@1.1.0
β”‚ β”‚ β”œβ”€β”€ escape-string-regexp@1.0.3
β”‚ β”‚ β”œβ”€β”¬ has-ansi@0.1.0
β”‚ β”‚ β”‚ └── ansi-regex@0.2.1
β”‚ β”‚ β”œβ”€β”¬ strip-ansi@0.3.0
β”‚ β”‚ β”‚ └── ansi-regex@0.2.1
β”‚ β”‚ └── supports-color@0.2.0
β”‚ β”œβ”€β”€ deprecated@0.0.1
+4
source share
3 answers

You can see the dependency tree using madge

+1
source

, module.parent module.children. . , package.json .

npm . - https://github.com/npm/npm

0

dependo

This is not a sort, but a visualization of your files.

0
source

All Articles