npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

--silent flag is passed down to npm in npm scripts?

Assume this package.json:

  "name": "repro",
  "version": "1.0.0",
  "dependencies": {
    "somethingthatdoesntexist": "1.0.0"
  "scripts": {
    "setup": "npm install && composer install"

When I’m running the setup I’m running it as npm run --silent setup, because when for example an error happens during composer install, I just want to see the composer error, not the whole “Failed at the repro setup script. This is probably not a problem with npm…” blah blah.

This works fine, --silent only suppresses the surrounding npm messages and leaves the composer error output intact.

However, if an error happens during the npm install (e.g. the missing “somethingthatdoesntexist” package), those errors are not shown. It seems that the --silent flag is somehow (environment variable?) passed down to the sub-process.

I wonder, by what mechanism is the flag passed down to subprocesses and is this desired behavior?

You’re idea is correct, it is environment variables. I verified this by having the script "setup": "npm config ls", which outputs, among other things:

> 130@1.0.0 setup /[...]/130
> npm config ls

; environment configs
loglevel = "silent"

Those are being passed down to such scripts on purpose, although this may still be an unintended side-effect.

Workaround: explicitly pass --loglevel=notice to npm in the setup script.