Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify that require.resolve automatically adds global folders to lookup path #18926

Closed
mojavelinux opened this issue Feb 22, 2018 · 1 comment
Labels
doc Issues and PRs related to the documentations.

Comments

@mojavelinux
Copy link

  • Version: v8.9.4
  • Platform: Fedora 26

It's not clear from the docs that require.resolve automatically adds the global folder to the module search path when using the paths option. It's clear that each path provided will be used as the starting point of a node_modules hierarchy. However, no where is it stated that the global folders (like ~/.node_modules) are added implicitly, leading one to assume that these paths are not search when the paths option is specified.

My proposed change is highlighted in bold.

Paths to resolve module location from. If present, these paths are used instead of the default resolution paths, with the exception of the global folders like ~/.node_modules, which are always included. Note that each of these paths is used as a starting point for the module resolution algorithm, meaning that the node_modules hierarchy is checked from this location.

I'd be happy to submit a patch if this proposed change is acceptable.

@joyeecheung joyeecheung added the doc Issues and PRs related to the documentations. label Feb 22, 2018
@joyeecheung
Copy link
Member

joyeecheung commented Feb 22, 2018

SGTM, it would also be helpful if there are some revisions in the resolution algorithm's documentation https://nodejs.org/api/modules.html#modules_all_together or an alternative one for the specified paths scenario.

targos pushed a commit that referenced this issue May 12, 2018
PR-URL: #20534
Fixes: #18926
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants