Lets say the module X has a Y submodule. From my node app that has a dependency on X, how can I require submodule Y?
var Y = require(\'X:Y\');
results
Submodule meaning an export from within the X module?
Try...
require('X/path-to-Y')
It's better to just declare Y as your own dependency. But if you really want to do that, here is how it's done:
// make sure that module X is loaded into a cache
require('X')
// get this module from cache
var module_X = require.cache[require.resolve('X')]
// require submodule Y
var Y = module_X.require('Y')