Skip to content

Commit 080c6cc

Browse files
committed
refactor: code
1 parent 415373e commit 080c6cc

1 file changed

Lines changed: 11 additions & 12 deletions

File tree

packages/webpack-cli/src/webpack-cli.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,6 @@ class WebpackCLI implements IWebpackCLI {
144144
return true;
145145
}
146146

147-
// Respect NODE_PATH environment variable
148-
try {
149-
if (
150-
process.env.NODE_PATH &&
151-
fs.statSync(path.join(process.env.NODE_PATH, packageName)).isDirectory()
152-
) {
153-
return true;
154-
}
155-
} catch (_error) {
156-
// Nothing
157-
}
158-
159147
let dir = __dirname;
160148

161149
do {
@@ -168,6 +156,17 @@ class WebpackCLI implements IWebpackCLI {
168156
}
169157
} while (dir !== (dir = path.dirname(dir)));
170158

159+
// https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274
160+
for (const internalPath of require("module").globalPaths) {
161+
try {
162+
if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) {
163+
return true;
164+
}
165+
} catch (_error) {
166+
// Nothing
167+
}
168+
}
169+
171170
return false;
172171
}
173172

0 commit comments

Comments
 (0)