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