From 7967eca11108abbf2f3433bd0361cc03522f175f Mon Sep 17 00:00:00 2001 From: musgravejw Date: Sat, 5 May 2018 01:43:12 -0400 Subject: [PATCH 1/3] doc: include global node_modules in require.resolve description --- doc/api/modules.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index c9b83859d99079..8fbc367183fb8f 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -175,7 +175,7 @@ LOAD_AS_DIRECTORY(X) 2. LOAD_INDEX(X) LOAD_NODE_MODULES(X, START) -1. let DIRS=NODE_MODULES_PATHS(START) +1. let DIRS = NODE_MODULES_PATHS(START) 2. for each DIR in DIRS: a. LOAD_AS_FILE(DIR/X) b. LOAD_AS_DIRECTORY(DIR/X) @@ -183,7 +183,7 @@ LOAD_NODE_MODULES(X, START) NODE_MODULES_PATHS(START) 1. let PARTS = path split(START) 2. let I = count of PARTS - 1 -3. let DIRS = [] +3. let DIRS = [ GLOBAL_FOLDERS ] 4. while I >= 0, a. if PARTS[I] = "node_modules" CONTINUE b. DIR = path join(PARTS[0 .. I] + "node_modules") @@ -649,9 +649,11 @@ changes: * `request` {string} The module path to resolve. * `options` {Object} * `paths` {string[]} Paths to resolve module location from. If present, these - paths are used instead of the default resolution paths. 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. + paths are used instead of the default resolution paths, with the exception + of 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. * Returns: {string} Use the internal `require()` machinery to look up the location of a module, From 263ad12914cea52fd6f611e32e62b70eaccda442 Mon Sep 17 00:00:00 2001 From: musgravejw Date: Sat, 5 May 2018 12:52:26 -0400 Subject: [PATCH 2/3] doc: rerence GLOBAL_FOLDERS and link to folder list --- doc/api/modules.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 8fbc367183fb8f..f17871b2e2afac 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -183,7 +183,7 @@ LOAD_NODE_MODULES(X, START) NODE_MODULES_PATHS(START) 1. let PARTS = path split(START) 2. let I = count of PARTS - 1 -3. let DIRS = [ GLOBAL_FOLDERS ] +3. let DIRS = [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders) 4. while I >= 0, a. if PARTS[I] = "node_modules" CONTINUE 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 module's dependencies change, causing a different version (or even a different module) to be loaded as the `NODE_PATH` is searched. -Additionally, Node.js will search in the following locations: +Additionally, Node.js will search in the following list of GLOBAL_FOLDERS: * 1: `$HOME/.node_modules` * 2: `$HOME/.node_libraries` @@ -650,10 +650,10 @@ changes: * `options` {Object} * `paths` {string[]} Paths to resolve module location from. If present, these paths are used instead of the default resolution paths, with the exception - of 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. + of [GLOBAL_FOLDERS](#modules_loading_from_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. * Returns: {string} Use the internal `require()` machinery to look up the location of a module, From c7e33fe7b9ad56f422fa32c8b0044871bf50633e Mon Sep 17 00:00:00 2001 From: musgravejw Date: Tue, 8 May 2018 14:49:41 -0400 Subject: [PATCH 3/3] doc: replace '~' with '$HOME', refactor --- doc/api/modules.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index f17871b2e2afac..0b2e326353e198 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -183,7 +183,7 @@ LOAD_NODE_MODULES(X, START) NODE_MODULES_PATHS(START) 1. let PARTS = path split(START) 2. let I = count of PARTS - 1 -3. let DIRS = [GLOBAL_FOLDERS](#modules_loading_from_the_global_folders) +3. let DIRS = [GLOBAL_FOLDERS] 4. while I >= 0, a. if PARTS[I] = "node_modules" CONTINUE b. DIR = path join(PARTS[0 .. I] + "node_modules") @@ -650,10 +650,10 @@ changes: * `options` {Object} * `paths` {string[]} Paths to resolve module location from. If present, these paths are used instead of the default resolution paths, with the exception - of [GLOBAL_FOLDERS](#modules_loading_from_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. + of [GLOBAL_FOLDERS][] like `$HOME/.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. * Returns: {string} Use the internal `require()` machinery to look up the location of a module, @@ -897,3 +897,4 @@ const builtin = require('module').builtinModules; [module resolution]: #modules_all_together [module wrapper]: #modules_the_module_wrapper [native addons]: addons.html +[GLOBAL_FOLDERS]: #modules_loading_from_the_global_folders