mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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>
This commit is contained in:
parent
b794f581b1
commit
51cd9719b5
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user