diff options
author | erickwendel <erick.workspace@gmail.com> | 2018-10-12 11:33:59 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-10-23 21:01:14 -0700 |
commit | 51cd9719b5fde5da973dcdbb196402b49f885c63 (patch) | |
tree | 6d8ecc070d1cb27ebde5f193218deb2f0d34f24b /doc | |
parent | b794f581b1475bccfe0606ab0fda49500bd58b6c (diff) | |
download | android-node-v8-51cd9719b5fde5da973dcdbb196402b49f885c63.tar.gz android-node-v8-51cd9719b5fde5da973dcdbb196402b49f885c63.tar.bz2 android-node-v8-51cd9719b5fde5da973dcdbb196402b49f885c63.zip |
doc: add review suggestions to require()
PR-URL: https://github.com/nodejs/node/pull/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>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/modules.md | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/doc/api/modules.md b/doc/api/modules.md index 59c589e83a..2475fa2755 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -552,7 +552,22 @@ added: v0.1.13 * {Function} -To require modules. +Used to import modules, `JSON`, and local files. Modules can be imported +from `node_modules`. Local modules and JSON files can be imported using +a relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be +resolved against the directory named by [`__dirname`][] (if defined) or +the current working directory. + +```js +// Importing a local module: +const myLocalModule = require('./path/myLocalModule'); + +// Importing a JSON file: +const jsonData = require('./path/filename.json'); + +// Importing a module from node_modules or Node.js built-in module: +const crypto = require('crypto'); +``` #### require.cache <!-- YAML |