1From a31425bdfcb5d695ab25c3d295898326784cffec Mon Sep 17 00:00:00 2001 2From: Thomas Petazzoni <thomas.petazzoni@bootlin.com> 3Date: Sun, 25 Sep 2022 11:10:06 +0200 4Subject: [PATCH] lib/internal/modules/cjs/loader.js: adjust default path to 5 search modules 6 7NPM installs modules in /usr/lib/node_modules/, but by default NodeJS 8searches for them only in /usr/lib/node/. We could also set the 9NODE_PATH environment variable, but it is more convienient to have 10NodeJS configured by default to find modules where they are installed. 11 12This issue is discussed at 13https://stackoverflow.com/questions/15636367/nodejs-require-a-global-module-package. 14 15Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> 16--- 17 lib/internal/modules/cjs/loader.js | 3 ++- 18 1 file changed, 2 insertions(+), 1 deletion(-) 19 20diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js 21index f1971c40a4..5fe3884156 100644 22--- a/lib/internal/modules/cjs/loader.js 23+++ b/lib/internal/modules/cjs/loader.js 24@@ -1378,7 +1378,8 @@ Module._initPaths = function() { 25 path.resolve(process.execPath, '..') : 26 path.resolve(process.execPath, '..', '..'); 27 28- const paths = [path.resolve(prefixDir, 'lib', 'node')]; 29+ const paths = [path.resolve(prefixDir, 'lib', 'node'), 30+ path.resolve(prefixDir, 'lib', 'node_modules')]; 31 32 if (homeDir) { 33 ArrayPrototypeUnshift(paths, path.resolve(homeDir, '.node_libraries')); 34-- 352.37.3 36 37