Skip to content

Commit 68e3229

Browse files
aduh95guangwong
authored andcommitted
doc: clarify core modules that can be loaded without a prefix
Refs: nodejs/node#42325 PR-URL: nodejs/node#42753 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Mestery <[email protected]>
1 parent 952e0e2 commit 68e3229

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

doc/api/modules.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,17 @@ described in greater detail elsewhere in this documentation.
331331
The core modules are defined within the Node.js source and are located in the
332332
`lib/` folder.
333333

334-
Core modules are always preferentially loaded if their identifier is
335-
passed to `require()`. For instance, `require('http')` will always
336-
return the built in HTTP module, even if there is a file by that name.
337-
338-
Core modules can also be identified using the `node:` prefix, in which case
334+
Core modules can be identified using the `node:` prefix, in which case
339335
it bypasses the `require` cache. For instance, `require('node:http')` will
340336
always return the built in HTTP module, even if there is `require.cache` entry
341337
by that name.
342338

339+
Some core modules are always preferentially loaded if their identifier is
340+
passed to `require()`. For instance, `require('http')` will always
341+
return the built-in HTTP module, even if there is a file by that name. The list
342+
of core modules that can be loaded without using the `node:` prefix is exposed
343+
as [`module.builtinModules`][].
344+
343345
## Cycles
344346

345347
<!--type=misc-->
@@ -1088,6 +1090,7 @@ This section was moved to
10881090
[`__dirname`]: #__dirname
10891091
[`__filename`]: #__filename
10901092
[`import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports
1093+
[`module.builtinModules`]: module.md#modulebuiltinmodules
10911094
[`module.children`]: #modulechildren
10921095
[`module.id`]: #moduleid
10931096
[`module` core module]: module.md

0 commit comments

Comments
 (0)