In node.JS how can I get the path of a module I have loaded via require that is *not* mine (i.e. in some node_module)

I require a module that was installed via npm. I want to access a .js file subordinate to that module (so I can subclass a Constructor method in it). I can't (well, don't want to) modify the module's code, so don't have a place to extract its __dirname.

I am aware of the following question, but it is about getting the path of a module that one has code control over (hence, __dirname is the solution): In Node.js how can I tell the path of `this` module?

~~~

Even better would be to get the module's loaded module info

If I correctly understand your question, you should use require.resolve():

Use the internal require() machinery to look up the location of a module, but rather than loading the module, just return the resolved filename.

I hope I correctly understand your needs: to get entry point file of some module. Let's say you want to get entry point of jugglingdb module:

node
> require('module')._resolveFilename('jugglingdb')
'/usr/local/lib/node_modules/jugglingdb/index.js'

As you can see this is not "official" way to get this kind of information about module, so behavior of this function may change from version to version. I've found it in node source: https://github.com/joyent/node/blob/master/lib/module.js#L280