Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e711e45

Browse filesBrowse files
ErickWendelMylesBorins
authored andcommitted
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 d62d666 commit e711e45
Copy full SHA for e711e45

File tree

Expand file treeCollapse file tree

1 file changed

+16
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/modules.md‎

Copy file name to clipboardExpand all lines: doc/api/modules.md
+16-1Lines changed: 16 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,22 @@ added: v0.1.13
552552

553553
* {Function}
554554

555-
To require modules.
555+
Used to import modules, `JSON`, and local files. Modules can be imported
556+
from `node_modules`. Local modules and JSON files can be imported using
557+
a relative path (e.g. `./`, `./foo`, `./bar/baz`, `../foo`) that will be
558+
resolved against the directory named by [`__dirname`][] (if defined) or
559+
the current working directory.
560+
561+
```js
562+
// Importing a local module:
563+
const myLocalModule = require('./path/myLocalModule');
564+
565+
// Importing a JSON file:
566+
const jsonData = require('./path/filename.json');
567+
568+
// Importing a module from node_modules or Node.js built-in module:
569+
const crypto = require('crypto');
570+
```
556571

557572
#### require.cache
558573
<!-- YAML

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.