What does -s mean in npm command?

2019-07-31 06:04发布

问题:

I saw the following command that includes -s option. What does it(-s) mean? Because I didn't see the option in package.json.

$ npm run dev -s

回答1:

The flag -s stands for "silent" and is applied to npm, not to the command in the dev script.

The -s flag prevents npm from screaming at you when the command exits with a non-zero status, i.e. when the command fails. It also won't create an npm_debug.log file.

To test out the difference yourself you can do the following in a new directory.

npm init -y
npm run test
npm run test -s

Note 1: I prefer to write npm run -s dev to limit possible confusion.

Note 2: To pass the -s flag to the dev script, you would run npm run dev -- -s.