From fde12c3a2f346f009e03706bc61b1835e785a4f0 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 28 Sep 2022 08:17:06 +0530 Subject: [PATCH 1/2] fix: respect NODE_PATH env variable --- bin/webpack.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/webpack.js b/bin/webpack.js index fead38bf4b1..2038efebd40 100755 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -53,6 +53,17 @@ const isInstalled = packageName => { } } while (dir !== (dir = path.dirname(dir))); + // https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274 + for (const internalPath of require("module").globalPaths) { + try { + if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) { + return true; + } + } catch (_error) { + // Nothing + } + } + return false; }; From 37cba1da968d5f108cb7812deffec724ef375241 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Wed, 28 Sep 2022 08:22:16 +0530 Subject: [PATCH 2/2] fix: lint issues --- bin/webpack.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/bin/webpack.js b/bin/webpack.js index 2038efebd40..aadab30c0d0 100755 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -54,13 +54,15 @@ const isInstalled = packageName => { } while (dir !== (dir = path.dirname(dir))); // https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274 - for (const internalPath of require("module").globalPaths) { + // eslint-disable-next-line no-warning-comments + // @ts-ignore + for (const internalPath of require("module").globalPaths) { try { - if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) { - return true; - } + if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) { + return true; + } } catch (_error) { - // Nothing + // Nothing } }