default npm run to silent #5452
Comments
In addition, it would be nice if |
it would also be nice if I could set a config to tell npm to never ever write a |
It would also be nice if the spinner is off by default for |
@Raynos npm is already too noisy, what do you think should be the default whitelist? I'm thinking anything npm runs should log otherwise it should shut up. EDIT: https://docs.npmjs.com/misc/scripts this gives that list. |
also how can you configure this if you do want output from npm? |
Sorry for the comment spam, but the more I think about this the more I don't like it. We already have an option |
@faiq You can even do It's more about default user experience. |
@Raynos the new |
@faiq that only applies if the |
so i guess the question still remains: if something breaks, and its not |
Here's my take: if a user script errors, the npm process should at the very least exit with a nonzero exit code. In addition, many times there will be useful information about the environment passed to a run-script that crashed, so |
@Raynos I agree with your initial request, this is too much noise imho. We should be able to specify that we want another log level for custom scripts than built-in Another thing, |
|
This spoils the use of custom NPM run-scripts for build & deployment abstraction. The run scripts have long exited with the appropriate exit code, but this involves write permissions for the machine/user. The stderr gets messy when EACCESS errors (for npm-debug.log) are thrown in. |
Is there anyway around this for the time being? |
Sorry see you can actually remove the noise by appending the --silent flag. |
my workaround for not writing that pesky
Now, if you DO want a command to be print output, it works fine to do
|
@samueleaton, no, it's not what aliases are for. Some utils will expect from "npm" to gave this log tail and will break because you substituted it. For example I was beaten by the very similar stuff nvm-sh/nvm#493 |
@ivan-kleshnin Thanks, I edited my comment. Dang, I want default silence when I'm linting... The fat npm error output takes up my whole terminal and I have to scroll up to see the linter output. At least there should be an option to have a single line error output from npm. I'm with @mnquintana that we should opt into the verbosity (its a whole paragraph of errors!). |
@samueleaton, everyone I asked is for silent default. That text tail is extremely annoying. |
Hey guys, I've opened a similar issue, trying to propose "alternatives": #8821. Thanks! |
This problem is amplified if you have a script setup where one npm script calls another via
In other words, 3 nested error warnings. And putting --silent after every Since npm is used more and more as a build tool, and we are supposed to run tests and linters with it, then the following message is not really appropriate when tests fail or linters encounter an error:
|
Here's what I'm using right now, for reference:
|
This would be wonderful Alternatively, if we were able to target specific commands via a Something like:
? |
I've set up a poll here to gather proposals: https://t.co/wr7gjnsR1b. |
I can't get the --silent flag to work at all when running npm (version 3.7.2) scripts from my package.json. The script runs fine, but when any tests fail, npm exits the process. My scripts are setup as follows...
I've tried just about every combination of adding the --silent (-s) flag, but I still get this nasty output when running lab through either of the above npm scripts:
When I run lab directly, I do not get the same logging naturally. Workaround I've managed to work around this issue by revising my test script to contain
I guess maybe lab is just too extreme with their exit codes. |
While we're thinking about the real solution, I wrote up a teeny utility called
|
I am working on an npm package commitplease which makes sure that a git commit message follows some style. When the commit message is bad, the script writes about it to stderr and exits with a non-zero code. The script itself is triggered by another npm package called husky. In a nutshell:
I have read the suggestions in this thread:
How could I silence npm when a particular |
I'm going to close this in favor of #8821, which has a more tightly scoped definition of the problem (as well as a proposal for what looks like a sensible solution). Thanks to all for your time and discussion! |
@ivan-kleshnin I know this thread is quite old, but I would like to rectify a statement:
This is wrong, @samueleaton was indeed right to suggest using an alias. Setting preferred flags, only when the commands are used interactively in a terminal, is exactly what Bash aliases are for. If a script breaks because you have an alias in your .bashrc, then there is something very wrong with that script or with your setup. Here's an example of how scripts completely ignore aliases:
|
When we use
npm run custom-script
, if the custom script exits 1 it currently outputsThis seems like a lot of noise for something that is not part of npm.
When I write a
npm run some-script
script I am expected to write useful things to stderr when I exit 1. The text generated by npm does actually not help.We might want to whitelist some certain run scripts like
npm run preinstall
etc so that it does output this.However for something truly custom like
npm run changelog-patch
ornpm run shrinkwrap
, run targets not used by npm at all, it might make sense to default tosilent: true
Suggestion
in
lib/run-script.js
if the run command is not in a whitelist of [postinstall, preinstall, etc, ...] then do annpm.config.set('silent', true)
The text was updated successfully, but these errors were encountered: