summaryrefslogtreecommitdiff
path: root/doc/api/module.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/api/module.md')
-rw-r--r--doc/api/module.md22
1 files changed, 11 insertions, 11 deletions
diff --git a/doc/api/module.md b/doc/api/module.md
index 749bd350ba..85ba9a79e2 100644
--- a/doc/api/module.md
+++ b/doc/api/module.md
@@ -1,4 +1,4 @@
-# Modules: `module` API
+# Modules: `node:module` API
<!--introduced_in=v12.20.0-->
@@ -12,7 +12,7 @@ added: v0.3.7
Provides general utility methods when interacting with instances of
`Module`, the [`module`][] variable often seen in [CommonJS][] modules. Accessed
-via `import 'module'` or `require('module')`.
+via `import 'node:module'` or `require('node:module')`.
### `module.builtinModules`
@@ -34,13 +34,13 @@ by the [module wrapper][]. To access it, require the `Module` module:
```mjs
// module.mjs
// In an ECMAScript module
-import { builtinModules as builtin } from 'module';
+import { builtinModules as builtin } from 'node:module';
```
```cjs
// module.cjs
// In a CommonJS module
-const builtin = require('module').builtinModules;
+const builtin = require('node:module').builtinModules;
```
### `module.createRequire(filename)`
@@ -55,7 +55,7 @@ added: v12.2.0
* Returns: {require} Require function
```mjs
-import { createRequire } from 'module';
+import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
// sibling-module.js is a CommonJS module.
@@ -73,9 +73,9 @@ builtin [ES Modules][] to match the properties of the [CommonJS][] exports. It
does not add or remove exported names from the [ES Modules][].
```js
-const fs = require('fs');
-const assert = require('assert');
-const { syncBuiltinESMExports } = require('module');
+const fs = require('node:fs');
+const assert = require('node:assert');
+const { syncBuiltinESMExports } = require('node:module');
fs.readFile = newAPI;
@@ -89,7 +89,7 @@ fs.newAPI = newAPI;
syncBuiltinESMExports();
-import('fs').then((esmFS) => {
+import('node:fs').then((esmFS) => {
// It syncs the existing readFile property with the new value
assert.strictEqual(esmFS.readFile, newAPI);
// readFileSync has been deleted from the required fs
@@ -122,13 +122,13 @@ To enable source map parsing, Node.js must be run with the flag
```mjs
// module.mjs
// In an ECMAScript module
-import { findSourceMap, SourceMap } from 'module';
+import { findSourceMap, SourceMap } from 'node:module';
```
```cjs
// module.cjs
// In a CommonJS module
-const { findSourceMap, SourceMap } = require('module');
+const { findSourceMap, SourceMap } = require('node:module');
```
<!-- Anchors to make sure old links find a target -->