From 18f6f8e0b092241b2a1d2228a51fd7254d44e38d Mon Sep 17 00:00:00 2001 From: erickwendel Date: Fri, 12 Oct 2018 11:33:59 -0700 Subject: [PATCH 1/2] docs: add review suggestions to require() --- doc/api/modules.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 59c589e83ac233..cd53eb2c76be40 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -552,7 +552,18 @@ 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 the pattern `'./'`. + +```js +// importing localModule +const myLocalModule = require('./path/myLocalModule'); + +// importing JSON file +const jsonData = require('./path/filename.json'); + +// importing module from node_modules or Node.js internals +const crypto = require('crypto'); +``` #### require.cache