You have to use npm run build --silent.
This isn’t documented in npm help, npm help run, or anything else obvious, but with some searching on the internet you can find out that apparently it is documented in npm help 7 config. You can also use the loglevel option in .npmrc.
The --silent (short: -s) option suppresses:
- The two lines beginning with
>that say what command you’re running. npm ERR!errors.- Creating an
npm-debug.logif there’s an error.
Note: using npm scripts to run other npm scripts may require you to use --silent more than once. Example package.json:
{
. . .
"scripts": {
"compile": "tsc",
"minify": "uglifyjs --some --options",
"build": "npm run compile && npm run minify"
}
}
If you do npm run build and TypeScript finds an error, then you’ll get the npm ERR! from both scripts. To suppress them, you have to change the build script to npm run compile --silent && npm run minify and run it with npm run build --silent.