Skip to content

Commit 7967eca

Browse files
committed
doc: include global node_modules in require.resolve description
1 parent 1cf7ef6 commit 7967eca

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

doc/api/modules.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -175,15 +175,15 @@ LOAD_AS_DIRECTORY(X)
175175
2. LOAD_INDEX(X)
176176
177177
LOAD_NODE_MODULES(X, START)
178-
1. let DIRS=NODE_MODULES_PATHS(START)
178+
1. let DIRS = NODE_MODULES_PATHS(START)
179179
2. for each DIR in DIRS:
180180
a. LOAD_AS_FILE(DIR/X)
181181
b. LOAD_AS_DIRECTORY(DIR/X)
182182
183183
NODE_MODULES_PATHS(START)
184184
1. let PARTS = path split(START)
185185
2. let I = count of PARTS - 1
186-
3. let DIRS = []
186+
3. let DIRS = [ GLOBAL_FOLDERS ]
187187
4. while I >= 0,
188188
a. if PARTS[I] = "node_modules" CONTINUE
189189
b. DIR = path join(PARTS[0 .. I] + "node_modules")
@@ -649,9 +649,11 @@ changes:
649649
* `request` {string} The module path to resolve.
650650
* `options` {Object}
651651
* `paths` {string[]} Paths to resolve module location from. If present, these
652-
paths are used instead of the default resolution paths. Note that each of
653-
these paths is used as a starting point for the module resolution algorithm,
654-
meaning that the `node_modules` hierarchy is checked from this location.
652+
paths are used instead of the default resolution paths, with the exception
653+
of global folders like `~/.node_modules`, which are always included. Note
654+
that each of these paths is used as a starting point for the module
655+
resolution algorithm, meaning that the `node_modules` hierarchy is checked
656+
from this location.
655657
* Returns: {string}
656658

657659
Use the internal `require()` machinery to look up the location of a module,

0 commit comments

Comments
 (0)