there's in a situation, npm bin print some warning msg such as:
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. // stderr
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead. // stderr
C:\Users\john\AppData\Roaming\npm //stdout
but your source code:
exec("npm bin -g", function(err, stdout, stderr) {
let dir = null;
if (err || stderr || !stdout || stdout.length === 0) {
// npm bin successfully print npm bin path with some warnings, but program goes to this branch.
let env = process.env;
if (env && env.npm_config_prefix) {
dir = path.join(env.npm_config_prefix, "bin");
}
} else {
dir = stdout.trim();
}
console.log(dir)
});
there's in a situation,
npm bin
print some warning msg such as:but your source code: