fix: respect NODE_PATH env variable

This commit is contained in:
Nitin Kumar 2022-09-28 08:17:06 +05:30 committed by Nitin Kumar
parent 9fcaa24357
commit 98375f6c95
1 changed files with 13 additions and 0 deletions

View File

@ -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;
};