Is it possible to access * loaded * children of a nodejs module?
Let's say I have 3 modules with dependencies like this:
A.js
var b = require('./B');
var c = require('./C');
console.log(module.children.length); // 2
B.js
var z = require('Z');
console.log(module.children.length); // 1
C.js
var z = require('Z');
console.log(module.children.length); // 0 ?!?!
Z
does not appear in the module.children
inside C
because it was already loaded B
before execution C
.
I can figure out module.parent
of Z
how B
because the first place was loaded, but Z
can certainly be a child of B
and C
?
Anyway, my question is, is it possible to see all the children of a module, regardless of whether they have been loaded or not?
source to share