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

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.

Example: var pathToModule = require.resolve('module');

Leave a Comment