@@ -280,6 +280,12 @@ irrespective of whether or not `./foo` and `./FOO` are the same file.
280280## Core modules
281281
282282<!-- type=misc-->
283+ <!-- YAML
284+ changes:
285+ - version: REPLACEME
286+ pr-url: https://github.com/nodejs/node/pull/37246
287+ description: Added `node:` import support to `require(...)`.
288+ -->
283289
284290Node.js has several modules compiled into the binary. These modules are
285291described in greater detail elsewhere in this documentation.
@@ -291,6 +297,11 @@ Core modules are always preferentially loaded if their identifier is
291297passed to ` require() ` . For instance, ` require('http') ` will always
292298return the built in HTTP module, even if there is a file by that name.
293299
300+ Core modules can also be identified using the ` node: ` prefix, in which case
301+ it bypasses the ` require ` cache. For instance, ` require('node:http') ` will
302+ always return the built in HTTP module, even if there is ` require.cache ` entry
303+ by that name.
304+
294305## Cycles
295306
296307<!-- type=misc-->
@@ -642,8 +653,19 @@ error.
642653
643654Adding or replacing entries is also possible. This cache is checked before
644655native modules and if a name matching a native module is added to the cache,
645- no require call is
646- going to receive the native module anymore. Use with care!
656+ only ` node: ` -prefixed require calls are going to receive the native module.
657+ Use with care!
658+
659+ ``` js
660+ const assert = require (' assert' );
661+ const realFs = require (' fs' );
662+
663+ const fakeFs = {};
664+ require .cache .fs = {exports: fakeFs };
665+
666+ assert .strictEqual (require (' fs' ), fakeFs);
667+ assert .strictEqual (require (' node:fs' ), realFs);
668+ ```
647669
648670#### ` require.extensions `
649671<!-- YAML
0 commit comments