File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -552,7 +552,22 @@ added: v0.1.13
552
552
553
553
* {Function}
554
554
555
- To require modules.
555
+ Used to import modules, ` JSON ` , and local files. Modules can be imported
556
+ from ` node_modules ` . Local modules and JSON files can be imported using
557
+ a relative path (e.g. ` ./ ` , ` ./foo ` , ` ./bar/baz ` , ` ../foo ` ) that will be
558
+ resolved against the directory named by [ ` __dirname ` ] [ ] (if defined) or
559
+ the current working directory.
560
+
561
+ ``` js
562
+ // Importing a local module:
563
+ const myLocalModule = require (' ./path/myLocalModule' );
564
+
565
+ // Importing a JSON file:
566
+ const jsonData = require (' ./path/filename.json' );
567
+
568
+ // Importing a module from node_modules or Node.js built-in module:
569
+ const crypto = require (' crypto' );
570
+ ```
556
571
557
572
#### require.cache
558
573
<!-- YAML
You can’t perform that action at this time.
0 commit comments