Skip to content

Commit 3f2a016

Browse files
ErickWendelrvagg
authored andcommitted
doc: add review suggestions to require()
PR-URL: #23605 Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Sakthipriyan Vairamani <[email protected]> Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 4996056 commit 3f2a016

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

doc/api/modules.md

+16-1
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)