From bb616a81bdbb3a1a14efff73a7c545dd7a6fbfb0 Mon Sep 17 00:00:00 2001 From: erickwendel Date: Fri, 12 Oct 2018 11:33:59 -0700 Subject: [PATCH] doc: add review suggestions to require() PR-URL: https://github.com/nodejs/node/pull/23605 Reviewed-By: Denys Otrishko Reviewed-By: Trivikram Kamat Reviewed-By: Gireesh Punathil --- doc/api/modules.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 59c589e83ac233..6891d9672957be 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -552,7 +552,20 @@ 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