Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

judge the warning as error #17

Open
oneslideicywater opened this issue Aug 22, 2022 · 0 comments
Open

judge the warning as error #17

oneslideicywater opened this issue Aug 22, 2022 · 0 comments

Comments

@oneslideicywater
Copy link

oneslideicywater commented Aug 22, 2022

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)
     

});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant