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
Post a Comment