diff --git a/bin/webpack-dev-server.js b/bin/webpack-dev-server.js index d5262fffa7..5cf7a3bd5a 100755 --- a/bin/webpack-dev-server.js +++ b/bin/webpack-dev-server.js @@ -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; };