@@ -313,7 +313,7 @@ required filename with the added extensions: `.js`, `.json`, and finally
313
313
314
314
` .js ` files are interpreted as JavaScript text files, and ` .json ` files are
315
315
parsed as JSON text files. ` .node ` files are interpreted as compiled addon
316
- modules loaded with ` dlopen ` .
316
+ modules loaded with ` process. dlopen() ` .
317
317
318
318
A required module prefixed with ` '/' ` is an absolute path to the file. For
319
319
example, ` require('/home/marco/foo.js') ` will load the file at
@@ -527,6 +527,8 @@ added: v0.1.12
527
527
528
528
<!-- type=var -->
529
529
530
+ * {Object}
531
+
530
532
A reference to the ` module.exports ` that is shorter to type.
531
533
See the section about the [ exports shortcut] [ ] for details on when to use
532
534
` exports ` and when to use ` module.exports ` .
@@ -538,20 +540,21 @@ added: v0.1.16
538
540
539
541
<!-- type=var -->
540
542
541
- * {Object }
543
+ * {module }
542
544
543
545
A reference to the current module, see the section about the
544
546
[ ` module ` object] [ ] . In particular, ` module.exports ` is used for defining what
545
547
a module exports and makes available through ` require() ` .
546
548
547
- ### require()
549
+ ### require(id )
548
550
<!-- YAML
549
551
added: v0.1.13
550
552
-->
551
553
552
554
<!-- type=var -->
553
555
554
- * {Function}
556
+ * ` id ` {string} module name or path
557
+ * Returns: {any} exported module content
555
558
556
559
Used to import modules, ` JSON ` , and local files. Modules can be imported
557
560
from ` node_modules ` . Local modules and JSON files can be imported using
@@ -600,7 +603,7 @@ Process files with the extension `.sjs` as `.js`:
600
603
require .extensions [' .sjs' ] = require .extensions [' .js' ];
601
604
```
602
605
603
- ** Deprecated** In the past, this list has been used to load
606
+ ** Deprecated. ** In the past, this list has been used to load
604
607
non-JavaScript modules into Node.js by compiling them on-demand.
605
608
However, in practice, there are much better ways to do this, such as
606
609
loading modules via some other Node.js program, or compiling them to
@@ -622,7 +625,7 @@ should be discouraged.
622
625
added: v0.1.17
623
626
-->
624
627
625
- * {Object }
628
+ * {module }
626
629
627
630
The ` Module ` object representing the entry script loaded when the Node.js
628
631
process launched.
@@ -676,7 +679,7 @@ changes:
676
679
Use the internal ` require() ` machinery to look up the location of a module,
677
680
but rather than loading the module, just return the resolved filename.
678
681
679
- #### require.resolve.paths(request)
682
+ ##### require.resolve.paths(request)
680
683
<!-- YAML
681
684
added: v8.9.0
682
685
-->
@@ -820,7 +823,7 @@ added: v0.1.16
820
823
821
824
* {string}
822
825
823
- The fully resolved filename to the module.
826
+ The fully resolved filename of the module.
824
827
825
828
### module.id
826
829
<!-- YAML
@@ -866,9 +869,9 @@ added: v0.5.1
866
869
-->
867
870
868
871
* ` id ` {string}
869
- * Returns: {Object} ` module.exports ` from the resolved module
872
+ * Returns: {any} exported module content
870
873
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
872
875
` require() ` was called from the original module.
873
876
874
877
In order to do this, it is necessary to get a reference to the ` module ` object.
@@ -912,7 +915,7 @@ added: v10.12.0
912
915
913
916
* ` filename ` {string} Filename to be used to construct the relative require
914
917
function.
915
- * Returns: {[ ` require ` ] [ ] } Require function
918
+ * Returns: {require} Require function
916
919
917
920
``` js
918
921
const { createRequireFromPath } = require (' module' );
@@ -922,13 +925,12 @@ const requireUtil = createRequireFromPath('../src/utils');
922
925
requireUtil (' ./some-tool' );
923
926
```
924
927
928
+ [ GLOBAL_FOLDERS ] : #modules_loading_from_the_global_folders
925
929
[ `Error` ] : errors.html#errors_class_error
926
930
[ `__dirname` ] : #modules_dirname
927
931
[ `__filename` ] : #modules_filename
928
932
[ `module` object ] : #modules_the_module_object
929
933
[ `path.dirname()` ] : path.html#path_path_dirname_path
930
- [ `require` ] : #modules_require
931
- [ GLOBAL_FOLDERS ] : #modules_loading_from_the_global_folders
932
934
[ exports shortcut ] : #modules_exports_shortcut
933
935
[ module resolution ] : #modules_all_together
934
936
[ module wrapper ] : #modules_the_module_wrapper
0 commit comments