Can I hide or silence “npm ERR!” output when using npm run script?

后端 未结 5 1401
余生分开走
余生分开走 2021-01-03 18:04

I\'m using npm run script to do tasks such as \"build\" and \"test\".

For example, my package.json looks like the following:

{
  \"name\         


        
5条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-03 18:23

    As others have noted, the problem with --silent is you lose all output. There's another way that seems to work for most cases:

    npm run something 2>/dev/null
    

    If one of the binaries you are running happens to write to stderr, then that will be suppressed. But most node stuff writes to stdout, so it shouldn't be a problem.

    Of course this will work only in a shell environment that supports output redirection.

提交回复
热议问题