| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4996056 commit 3f2a016
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -551,7 +551,22 @@ added: v0.1.13 | |||
| 551 | 551 | ||
| 552 | 552 | * {Function} | |
| 553 | 553 | ||
| 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 | + ``` | ||
| 555 | 570 | ||
| 556 | 571 | #### require.cache | |
| 557 | 572 | <!-- YAML | |
| Back | FazBrowse Home | New Git URL |
0 commit comments