@@ -175,15 +175,15 @@ LOAD_AS_DIRECTORY(X)
1751752. LOAD_INDEX(X)
176176
177177LOAD_NODE_MODULES(X, START)
178- 1. let DIRS= NODE_MODULES_PATHS(START)
178+ 1. let DIRS = NODE_MODULES_PATHS(START)
1791792. for each DIR in DIRS:
180180 a. LOAD_AS_FILE(DIR/X)
181181 b. LOAD_AS_DIRECTORY(DIR/X)
182182
183183NODE_MODULES_PATHS(START)
1841841. let PARTS = path split(START)
1851852. let I = count of PARTS - 1
186- 3. let DIRS = []
186+ 3. let DIRS = [GLOBAL_FOLDERS ]
1871874. while I >= 0,
188188 a. if PARTS[I] = "node_modules" CONTINUE
189189 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
419419module's dependencies change, causing a different version (or even a
420420different module) to be loaded as the ` NODE_PATH ` is searched.
421421
422- Additionally, Node.js will search in the following locations :
422+ Additionally, Node.js will search in the following list of GLOBAL_FOLDERS :
423423
424424* 1: ` $HOME/.node_modules `
425425* 2: ` $HOME/.node_libraries `
@@ -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 ` $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.
655657* Returns: {string}
656658
657659Use the internal ` require() ` machinery to look up the location of a module,
@@ -891,6 +893,7 @@ const builtin = require('module').builtinModules;
891893[ `Error` ] : errors.html#errors_class_error
892894[ `module` object ] : #modules_the_module_object
893895[ `path.dirname()` ] : path.html#path_path_dirname_path
896+ [ GLOBAL_FOLDERS ] : #modules_loading_from_the_global_folders
894897[ exports shortcut ] : #modules_exports_shortcut
895898[ module resolution ] : #modules_all_together
896899[ module wrapper ] : #modules_the_module_wrapper
0 commit comments