77* {Object}
88
99Provides general utility methods when interacting with instances of
10- ` Module ` , the ` module ` variable often seen in file modules. Accessed
11- via ` require('module') ` .
10+ ` Module ` , the [ ` module ` ] [ ] variable often seen in [ CommonJS ] [ ] modules. Accessed
11+ via ` import 'module' ` or ` require('module') ` .
1212
1313### ` module.builtinModules `
1414<!-- YAML
@@ -27,6 +27,14 @@ if a module is maintained by a third party or not.
2727by the [ module wrapper] [ ] . To access it, require the ` Module ` module:
2828
2929``` js
30+ // module.mjs
31+ // In an ECMAScript module
32+ import { builtinModules as builtin } from ' module' ;
33+ ```
34+
35+ ``` js
36+ // module.cjs
37+ // In a CommonJS module
3038const builtin = require (' module' ).builtinModules ;
3139```
3240
@@ -74,8 +82,8 @@ added: v12.12.0
7482-->
7583
7684The ` module .syncBuiltinESMExports ()` method updates all the live bindings for
77- builtin ES Modules to match the properties of the CommonJS exports. It does
78- not add or remove exported names from the ES Modules.
85+ builtin [ ES Modules][] to match the properties of the [ CommonJS][] exports. It
86+ does not add or remove exported names from the [ ES Modules][] .
7987
8088` ` ` js
8189const fs = require (' fs' );
@@ -116,6 +124,14 @@ To enable source map parsing, Node.js must be run with the flag
116124[` NODE_V8_COVERAGE = dir` ][].
117125
118126` ` ` js
127+ // module.mjs
128+ // In an ECMAScript module
129+ import { findSourceMap , SourceMap } from ' module' ;
130+ ` ` `
131+
132+ ` ` ` js
133+ // module.cjs
134+ // In a CommonJS module
119135const { findSourceMap , SourceMap } = require (' module' );
120136` ` `
121137
@@ -192,3 +208,6 @@ consists of the following keys:
192208[` Error .prepareStackTrace (error, trace)` ]: https://v8.dev/docs/stack-trace-api#customizing-stack-traces
193209[` SourceMap` ]: #module_class_module_sourcemap
194210[Source map v3 format]: https://sourcemaps.info/spec.html#h.mofvlxcwqzej
211+ [` module ` ]: modules.html#modules_the_module_object
212+ [CommonJS]: modules.html
213+ [ES Modules]: esm.html
0 commit comments