Skip to content

Commit b857e6f

Browse files
authored
fix: respect NODE_PATH env variable (#4581)
1 parent 87c08f1 commit b857e6f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bin/webpack-dev-server.js

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ const isInstalled = (packageName) => {
5858
// eslint-disable-next-line no-cond-assign
5959
} while (dir !== (dir = path.dirname(dir)));
6060

61+
// https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274
62+
// @ts-ignore
63+
for (const internalPath of require("module").globalPaths) {
64+
try {
65+
if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) {
66+
return true;
67+
}
68+
} catch (_error) {
69+
// Nothing
70+
}
71+
}
72+
6173
return false;
6274
};
6375

0 commit comments

Comments
 (0)