-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
module: createRequireFromPath documentation is incorrect #23710
Copy link
Copy link
Closed
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.Issues that need assistance from volunteers or PRs that need help to proceed.moduleIssues and PRs related to the module subsystem.Issues and PRs related to the module subsystem.
The documentation for
createRequireFromPathmakes it seem like you can pass a directory to the function, but that will never correctly resolve packages.Using the following directory structure;
The following code will throw a
MODULE_NOT_FOUNDexception (example from the docs):However, if we pass a file path we can resolve it just fine.
Is there a bug here or is the documentation wrong? I'm willing to make a PR to either fix the issue or update the documentation :)