Skip to content

Commit 46c880b

Browse files
aduh95targos
authored andcommitted
doc: clarify core modules that can be loaded without a prefix
Refs: #42325 PR-URL: #42753 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Jacob Smith <[email protected]> Reviewed-By: Mestery <[email protected]>
1 parent c3922af commit 46c880b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

doc/api/modules.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,17 @@ described in greater detail elsewhere in this documentation.
333333
The core modules are defined within the Node.js source and are located in the
334334
`lib/` folder.
335335

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

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

347349
<!--type=misc-->
@@ -1092,6 +1094,7 @@ This section was moved to
10921094
[`__dirname`]: #__dirname
10931095
[`__filename`]: #__filename
10941096
[`import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports
1097+
[`module.builtinModules`]: module.md#modulebuiltinmodules
10951098
[`module.children`]: #modulechildren
10961099
[`module.id`]: #moduleid
10971100
[`module` core module]: module.md

0 commit comments

Comments
 (0)