fix: respect NODE_PATH env variable
This commit is contained in:
parent
9fcaa24357
commit
98375f6c95
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue