Skip to content

Commit

Permalink
Merge pull request #16808 from snitin315/fix-node-path
Browse files Browse the repository at this point in the history
fix: respect `NODE_PATH` env variable
  • Loading branch information
TheLarkInn committed Mar 21, 2023
2 parents 4a4ba2c + 98375f6 commit b604d78
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bin/webpack.js
Expand Up @@ -53,6 +53,19 @@ const isInstalled = packageName => {
}
} while (dir !== (dir = path.dirname(dir)));

// https://github.com/nodejs/node/blob/v18.9.1/lib/internal/modules/cjs/loader.js#L1274
// eslint-disable-next-line no-warning-comments
// @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 b604d78

Please sign in to comment.