Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1e20c5e

Browse filesBrowse files
vsemozhetbytaddaleax
authored andcommitted
doc: make modules.md more accurate
PR-URL: #25357 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 8d0c638 commit 1e20c5e
Copy full SHA for 1e20c5e

File tree

Expand file treeCollapse file tree

5 files changed

+19
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+19
-16
lines changed
Open diff view settings
Collapse file

‎doc/api/addons.md‎

Copy file name to clipboardExpand all lines: doc/api/addons.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -1377,5 +1377,5 @@ require('./build/Release/addon');
13771377
[installation instructions]: https://github.com/nodejs/node-gyp#installation
13781378
[libuv]: https://github.com/libuv/libuv
13791379
[node-gyp]: https://github.com/nodejs/node-gyp
1380-
[require]: modules.html#modules_require
1380+
[require]: modules.html#modules_require_id
13811381
[v8-docs]: https://v8docs.nodesource.com/
Collapse file

‎doc/api/errors.md‎

Copy file name to clipboardExpand all lines: doc/api/errors.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2188,7 +2188,7 @@ such as `process.stdout.on('data')`.
21882188
[`process.setUncaughtExceptionCaptureCallback()`]: process.html#process_process_setuncaughtexceptioncapturecallback_fn
21892189
[`readable._read()`]: stream.html#stream_readable_read_size_1
21902190
[`require('crypto').setEngine()`]: crypto.html#crypto_crypto_setengine_engine_flags
2191-
[`require()`]: modules.html#modules_require
2191+
[`require()`]: modules.html#modules_require_id
21922192
[`server.close()`]: net.html#net_server_close_callback
21932193
[`server.listen()`]: net.html#net_server_listen
21942194
[`sign.sign()`]: crypto.html#crypto_sign_sign_privatekey_outputencoding
Collapse file

‎doc/api/globals.md‎

Copy file name to clipboardExpand all lines: doc/api/globals.md
+1-1Lines changed: 1 addition & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ The object that acts as the namespace for all W3C
242242
[`exports`]: modules.html#modules_exports
243243
[`module`]: modules.html#modules_module
244244
[`process` object]: process.html#process_process
245-
[`require()`]: modules.html#modules_require
245+
[`require()`]: modules.html#modules_require_id
246246
[`setImmediate`]: timers.html#timers_setimmediate_callback_args
247247
[`setInterval`]: timers.html#timers_setinterval_callback_delay_args
248248
[`setTimeout`]: timers.html#timers_settimeout_callback_delay_args
Collapse file

‎doc/api/modules.md‎

Copy file name to clipboardExpand all lines: doc/api/modules.md
+15-13Lines changed: 15 additions & 13 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ required filename with the added extensions: `.js`, `.json`, and finally
313313

314314
`.js` files are interpreted as JavaScript text files, and `.json` files are
315315
parsed as JSON text files. `.node` files are interpreted as compiled addon
316-
modules loaded with `dlopen`.
316+
modules loaded with `process.dlopen()`.
317317

318318
A required module prefixed with `'/'` is an absolute path to the file. For
319319
example, `require('/home/marco/foo.js')` will load the file at
@@ -527,6 +527,8 @@ added: v0.1.12
527527

528528
<!-- type=var -->
529529

530+
* {Object}
531+
530532
A reference to the `module.exports` that is shorter to type.
531533
See the section about the [exports shortcut][] for details on when to use
532534
`exports` and when to use `module.exports`.
@@ -538,20 +540,21 @@ added: v0.1.16
538540

539541
<!-- type=var -->
540542

541-
* {Object}
543+
* {module}
542544

543545
A reference to the current module, see the section about the
544546
[`module` object][]. In particular, `module.exports` is used for defining what
545547
a module exports and makes available through `require()`.
546548

547-
### require()
549+
### require(id)
548550
<!-- YAML
549551
added: v0.1.13
550552
-->
551553

552554
<!-- type=var -->
553555

554-
* {Function}
556+
* `id` {string} module name or path
557+
* Returns: {any} exported module content
555558

556559
Used to import modules, `JSON`, and local files. Modules can be imported
557560
from `node_modules`. Local modules and JSON files can be imported using
@@ -600,7 +603,7 @@ Process files with the extension `.sjs` as `.js`:
600603
require.extensions['.sjs'] = require.extensions['.js'];
601604
```
602605

603-
**Deprecated** In the past, this list has been used to load
606+
**Deprecated.** In the past, this list has been used to load
604607
non-JavaScript modules into Node.js by compiling them on-demand.
605608
However, in practice, there are much better ways to do this, such as
606609
loading modules via some other Node.js program, or compiling them to
@@ -622,7 +625,7 @@ should be discouraged.
622625
added: v0.1.17
623626
-->
624627

625-
* {Object}
628+
* {module}
626629

627630
The `Module` object representing the entry script loaded when the Node.js
628631
process launched.
@@ -676,7 +679,7 @@ changes:
676679
Use the internal `require()` machinery to look up the location of a module,
677680
but rather than loading the module, just return the resolved filename.
678681

679-
#### require.resolve.paths(request)
682+
##### require.resolve.paths(request)
680683
<!-- YAML
681684
added: v8.9.0
682685
-->
@@ -820,7 +823,7 @@ added: v0.1.16
820823

821824
* {string}
822825

823-
The fully resolved filename to the module.
826+
The fully resolved filename of the module.
824827

825828
### module.id
826829
<!-- YAML
@@ -866,9 +869,9 @@ added: v0.5.1
866869
-->
867870

868871
* `id` {string}
869-
* Returns: {Object} `module.exports` from the resolved module
872+
* Returns: {any} exported module content
870873

871-
The `module.require` method provides a way to load a module as if
874+
The `module.require()` method provides a way to load a module as if
872875
`require()` was called from the original module.
873876

874877
In order to do this, it is necessary to get a reference to the `module` object.
@@ -912,7 +915,7 @@ added: v10.12.0
912915

913916
* `filename` {string} Filename to be used to construct the relative require
914917
function.
915-
* Returns: {[`require`][]} Require function
918+
* Returns: {require} Require function
916919

917920
```js
918921
const { createRequireFromPath } = require('module');
@@ -922,13 +925,12 @@ const requireUtil = createRequireFromPath('../src/utils');
922925
requireUtil('./some-tool');
923926
```
924927

928+
[GLOBAL_FOLDERS]: #modules_loading_from_the_global_folders
925929
[`Error`]: errors.html#errors_class_error
926930
[`__dirname`]: #modules_dirname
927931
[`__filename`]: #modules_filename
928932
[`module` object]: #modules_the_module_object
929933
[`path.dirname()`]: path.html#path_path_dirname_path
930-
[`require`]: #modules_require
931-
[GLOBAL_FOLDERS]: #modules_loading_from_the_global_folders
932934
[exports shortcut]: #modules_exports_shortcut
933935
[module resolution]: #modules_all_together
934936
[module wrapper]: #modules_the_module_wrapper
Collapse file

‎tools/doc/type-parser.js‎

Copy file name to clipboardExpand all lines: tools/doc/type-parser.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const customTypesMap = {
9292
'https.Server': 'https.html#https_class_https_server',
9393

9494
'module': 'modules.html#modules_the_module_object',
95+
'require': 'modules.html#modules_require_id',
9596

9697
'Handle': 'net.html#net_server_listen_handle_backlog_callback',
9798
'net.Server': 'net.html#net_class_net_server',

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.