Skip to content

Commit 83d1f58

Browse files
snitin315alexander-akait
authored andcommittedNov 15, 2022
fix: respect NODE_PATH env variable (#3411)
1 parent 7c9ece2 commit 83d1f58

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
 

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

+11
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ class WebpackCLI implements IWebpackCLI {
156156
}
157157
} while (dir !== (dir = path.dirname(dir)));
158158

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+
159170
return false;
160171
}
161172

0 commit comments

Comments
 (0)
Please sign in to comment.