From ac025f17b27660ffacc150b4e7114478c81fe371 Mon Sep 17 00:00:00 2001 From: Qingyu Deng Date: Wed, 15 Dec 2021 02:51:24 +0800 Subject: [PATCH] doc: align module resolve algorithm with implementation Fixes: https://github.com/nodejs/node/issues/38128 PR-URL: https://github.com/nodejs/node/pull/38837 Reviewed-By: Guy Bedford --- doc/api/modules.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/modules.md b/doc/api/modules.md index 5f9dd5be0ea979..24dbccdb8c6a5c 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -197,13 +197,13 @@ 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 = [] 4. while I >= 0, a. if PARTS[I] = "node_modules" CONTINUE b. DIR = path join(PARTS[0 .. I] + "node_modules") - c. DIRS = DIRS + DIR + c. DIRS = DIR + DIRS d. let I = I - 1 -5. return DIRS +5. return DIRS + GLOBAL_FOLDERS LOAD_PACKAGE_IMPORTS(X, DIR) 1. Find the closest package scope SCOPE to DIR.