-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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.
Description
- Version: v10.12.0
- Platform: MacOS 10.14 (Darwin)
- Subsystem:
The documentation for createRequireFromPath makes it seem like you can pass a directory to the function, but that will never correctly resolve packages.
Using the following directory structure;
src/
└── utils
└── some-tool.js
The following code will throw a MODULE_NOT_FOUND exception (example from the docs):
const { createRequireFromPath } = require('module');
createRequireFromPath('../src/utils')('some-tool');However, if we pass a file path we can resolve it just fine.
const { createRequireFromPath } = require('module');
createRequireFromPath('../src/utils/index.js')('some-tool');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 :)
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.