Nodejs module.require and require

The node doc has a section about module.require:

module.require (ID)

Added in: v0.5.1 I'd Returns: module.exports from an allowed module The module.require method provides a way to load a module as if require () were called from the original module.

Note that for this you must get a reference to the module object. Since require () returns module.exports, and a module is usually only available within certain module code, it must be explicitly exported for use.

What is the exact meaning of "load a module as if require () were called from the source module ??

+3


source to share





All Articles