--silent doesn't suppress result logging with npm init -y #15425

insin opened this Issue Jan 7, 2017 · 2 comments


None yet

3 participants

insin commented Jan 7, 2017 edited

What's going wrong?

npm init -y --silent doesn't suppress Wrote to /path/to/package.json logging, which includes a full listing of the generated packge.json.

How can the CLI team reproduce the problem?

Run npm init -y --silent

supporting information:

  • npm -v prints: 3.10.8

init-package-json supports a silent option, but passing --silent to npm actually sets loglevel to 'silent' in npm config, so when init-package-json calls config.get('silent'), the result is undefined.

I would submit a PR, but I'm not sure which repository it should go to - should init-package-json be updated to also check if config.get('loglevel') === 'silent', or should npm set silent to true in its config when loglevel config is being set to 'silent'?

@insin insin referenced this issue in webpack-contrib/npm-install-webpack-plugin Jan 7, 2017

Add a quiet option #93


I would say the second one, but we would want @iarna's input

iarna commented Jan 10, 2017 edited

Currently --silent is explicitly documented as an alias of --logevel=silent.

## Shorthands and Other CLI Niceties

The following shorthands are parsed on the command-line:

* `-s`, `--silent`: `--loglevel silent`

Changing that for just one command means that --silent would then behave inconsistently. If you'd like to see --silent's behavior change, I'd like to see a proposal for how it should work across the npm cli. Is that suppressing all output? What if someone also passed in --json or --paresable? What if they're running something like npm init but didn't pass in -y? What about auth prompts from git or lifecycle scripts? Are those just hidden? I'd want to see this discussed for each of the commands as those are just the wrinkles I can think of off hand.

Once we've nailed down the details and we have consensus that the proposal is sound then we can discuss how to specifically implement that across all of the cli's commands.

(If you just want to suppress all output in this one case then > /dev/null works pretty well.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment