Skip to content

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

Closed
@mojavelinux

Description

@mojavelinux
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions