Skip to content

Commit

Permalink
doc: clarify core modules that can be loaded without a prefix
Browse files Browse the repository at this point in the history
Refs: nodejs#42325

PR-URL: nodejs#42753
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Jacob Smith <[email protected]>
Reviewed-By: Mestery <[email protected]>
  • Loading branch information
aduh95 authored and xtx1130 committed Apr 25, 2022
1 parent 2e16a4e commit c69da56
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions doc/api/modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,17 @@ described in greater detail elsewhere in this documentation.
The core modules are defined within the Node.js source and are located in the
`lib/` folder.

Core modules are always preferentially loaded if their identifier is
passed to `require()`. For instance, `require('http')` will always
return the built in HTTP module, even if there is a file by that name.

Core modules can also be identified using the `node:` prefix, in which case
Core modules can be identified using the `node:` prefix, in which case
it bypasses the `require` cache. For instance, `require('node:http')` will
always return the built in HTTP module, even if there is `require.cache` entry
by that name.

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

## Cycles

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

0 comments on commit c69da56

Please sign in to comment.