Skip to content

Commit

Permalink
fix: respect NODE_PATH env variable (#4581)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Sep 27, 2022
1 parent 87c08f1 commit b857e6f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ const isInstalled = (packageName) => {
// eslint-disable-next-line no-cond-assign
} while (dir !== (dir = path.dirname(dir)));

// https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274
// @ts-ignore
for (const internalPath of require("module").globalPaths) {
try {
if (fs.statSync(path.join(internalPath, packageName)).isDirectory()) {
return true;
}
} catch (_error) {
// Nothing
}
}

return false;
};

Expand Down

0 comments on commit b857e6f

Please sign in to comment.