doc fix: align code example for module.createRequireFromPath() with actual code behavior.#26606
doc fix: align code example for module.createRequireFromPath() with actual code behavior.#26606creativecomposer wants to merge 1 commit intonodejs:masterfrom creativecomposer:23710-doc-fix
Conversation
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: #23710 Refs: #24763 (comment)
|
@Antony2025 thanks a lot for the PR! Since there is an open PR that pretty much does the same as your, I would rather get that over the finish line instead. I hope that is OK? |
|
@BridgeAR remember the other open PR assumes that the directory taking PR is already landed. Therefore, the other PR must be changed so that it reflects the current code behavior: module.createRequireFromPath() works fine only when a file name is passed. See @Trott comment there: #24763 (comment) |
|
Hi @BridgeAR and @guybedford , Quite frankly, I do not see any response from the other PR author for @Trott review comment, therefore I would much rather prefer my PR - which is as per @Trott comment - to be merged. Anyway, up to you guys to decide. |
|
Closing this PR, because there is another open PR to address the issue. |
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: #23710
Refs: #24763 (comment)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes