GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add review suggestions to require() · nodejs/node@dd5afbe

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc/api
    • modules.md
Expand file treeCollapse file tree
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)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.