javascript - Is it possible to access *loaded* children of a nodejs module? -


say have 3 modules dependencies so:

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 doesn't appear in module.children inside c because loaded b before c executed.

i can understand module.parent of z being b because that's first place loaded, surely z can child of both b , c?

anyway, question: possible see all children of module, regardless of whether they've been loaded or not?

i had similar issue in past , manually deleted cache, in case module c.

c.js

delete require.cache[require.resolve('./z')]; var z = require('./z'); // 1 

i'm not sure if feasible solution though.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -