From 72d0853483b83b98d0f5f0fce64a96ee7a3fa65b Mon Sep 17 00:00:00 2001 From: Antony J Date: Tue, 12 Mar 2019 11:05:26 +0100 Subject: [PATCH] doc: align code example with actual code behavior module.createRequireFromPath() takes a filename as argument. But the accompanying code example in the documentation makes it seem like it can take a directory argument as well. However, if a directory is passed as argument instead of a filename, then the function does not work as expected. Therefore, the fix is to make explicit in the code example that only filenames could be passed to module.createRequireFromPath() and not directory names. Fixes: https://github.com/nodejs/node/issues/23710 Refs: https://github.com/nodejs/node/pull/24763#discussion_r238051920 --- doc/api/modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 5ef61141a6353c..ab526e9f492706 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -919,7 +919,7 @@ added: v10.12.0 ```js const { createRequireFromPath } = require('module'); -const requireUtil = createRequireFromPath('../src/utils'); +const requireUtil = createRequireFromPath('../src/utils/index.js'); // Require `../src/utils/some-tool` requireUtil('./some-tool');