module.require(id)
module.require()
方法提供了一种加载模块的方法,就像从原始模块调用 require()
一样。
为此,必须获得对 module
对象的引用。
由于 require()
返回 module.exports
,而 module
通常仅在特定模块的代码中可用,因此必须明确导出才能使用。
The module.require()
method provides a way to load a module as if
require()
was called from the original 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.