Skip to content

Commit 3f2a016

Browse files
ErickWendelrvagg
authored andcommittedNov 28, 2018
doc: add review suggestions to require()
PR-URL: #23605 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4996056 commit 3f2a016

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed
 

Diff for: ‎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)
Please sign in to comment.