@@ -175,15 +175,15 @@ LOAD_AS_DIRECTORY(X)
175
175
2. LOAD_INDEX(X)
176
176
177
177
LOAD_NODE_MODULES(X, START)
178
- 1. let DIRS= NODE_MODULES_PATHS(START)
178
+ 1. let DIRS = NODE_MODULES_PATHS(START)
179
179
2. for each DIR in DIRS:
180
180
a. LOAD_AS_FILE(DIR/X)
181
181
b. LOAD_AS_DIRECTORY(DIR/X)
182
182
183
183
NODE_MODULES_PATHS(START)
184
184
1. let PARTS = path split(START)
185
185
2. let I = count of PARTS - 1
186
- 3. let DIRS = []
186
+ 3. let DIRS = [GLOBAL_FOLDERS ]
187
187
4. while I >= 0,
188
188
a. if PARTS[I] = "node_modules" CONTINUE
189
189
b. DIR = path join(PARTS[0 .. I] + "node_modules")
@@ -419,7 +419,7 @@ when people are unaware that `NODE_PATH` must be set. Sometimes a
419
419
module's dependencies change, causing a different version (or even a
420
420
different module) to be loaded as the ` NODE_PATH ` is searched.
421
421
422
- Additionally, Node.js will search in the following locations :
422
+ Additionally, Node.js will search in the following list of GLOBAL_FOLDERS :
423
423
424
424
* 1: ` $HOME/.node_modules `
425
425
* 2: ` $HOME/.node_libraries `
@@ -649,9 +649,11 @@ changes:
649
649
* ` request ` {string} The module path to resolve.
650
650
* ` options ` {Object}
651
651
* ` 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 ` $HOME/.node_modules ` , which are always
654
+ included. Note that each of these paths is used as a starting point for
655
+ the module resolution algorithm, meaning that the ` node_modules ` hierarchy
656
+ is checked from this location.
655
657
* Returns: {string}
656
658
657
659
Use the internal ` require() ` machinery to look up the location of a module,
@@ -891,6 +893,7 @@ const builtin = require('module').builtinModules;
891
893
[ `Error` ] : errors.html#errors_class_error
892
894
[ `module` object ] : #modules_the_module_object
893
895
[ `path.dirname()` ] : path.html#path_path_dirname_path
896
+ [ GLOBAL_FOLDERS ] : #modules_loading_from_the_global_folders
894
897
[ exports shortcut ] : #modules_exports_shortcut
895
898
[ module resolution ] : #modules_all_together
896
899
[ module wrapper ] : #modules_the_module_wrapper
0 commit comments