Module
In each module, the module
free variable is a reference to the object representing the current module.
For convenience, module.exports
is also accessible via the exports
module-global.
module
is not actually a global but rather local to each module.
Static Members
A list of the names of all modules provided by Node.js. Can be used to verify if a module is maintained by a third party or not.
createRequire(filename: String): Function
Name | Type |
---|---|
filename |
String |
Returns |
---|
Function |
syncBuiltinESMExports(): Void
The module.syncBuiltinESMExports()
method updates all the live bindings for builtin ES Modules to match the
properties of the CommonJS exports.
It does not add or remove exported names from the ES Modules.
Instance Members
The module objects required for the first time by this one.
exports: Dynamic
The module.exports
object is created by the Module system.
Sometimes this is not acceptable; many want their module to be an instance of some class.
To do this, assign the desired export object to module.exports
.
Assigning the desired object to exports
will simply rebind the local exports
variable, which is probably not
what is desired.
filename: String
The fully resolved filename of the module.
id: String
The identifier for the module. Typically this is the fully resolved filename.
loaded: Bool
Whether or not the module is done loading, or is in the process of loading.
parent: Module
The module that first required this one.
The search paths for the module.
The module.require()
method provides a way to load a module as if require()
was called from the original
module.
Name | Type |
---|---|
id |
String |
Returns |
---|
Dynamic |
Metadata
Name | Parameters |
---|---|
:jsRequire |
"module" |