npm-cli-dir
Version:
Resolve the directory path where npm CLI is installed
24 lines (18 loc) • 387 B
JavaScript
;
const findPkgDir = require('find-pkg-dir');
const npmCliPath = require('npm-cli-path');
let path;
const firstTry = (async () => {
try {
path = findPkgDir(await npmCliPath());
} catch {
return false;
}
return true;
})();
module.exports = async function npmCliDir() {
if (!path && !await firstTry) {
path = findPkgDir(await npmCliPath());
}
return path;
};