0004-lib-internal-modules-cjs-loader.js-adjust-default-pa.patch 1.4 KB

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