module.require(id)


  • id <string>

  • 返回:<any> 导出的模块内容

    ¥Returns: <any> exported module content

module.require() 方法提供了一种加载模块的方法,就像从原始模块调用 require() 一样。

¥The module.require() method provides a way to load a module as if require() was called from the original module.

为此,必须获得对 module 对象的引用。由于 require() 返回 module.exports,而 module 通常仅在特定模块的代码中可用,因此必须显式导出才能使用。

¥In order to do this, it is necessary to get a reference to the module object. Since require() returns the module.exports, and the module is typically only available within a specific module's code, it must be explicitly exported in order to be used.