Typically this used as:

$ npm run COMMAND

Where COMMAND is a value from the scripts section of package.son.

CLI

Help

See npm run-script in the docs.

npm run-script <command> [--silent] [-- <args>...]

alias: npm run

Flags

You can use the –if-present flag to avoid exiting with a non-zero exit code when the script is undefined. This lets you run potentially undefined scripts without breaking the execution chain.

e.g.

$ npn run build --if-present

Pass ad hoc arguments

Use -- to indicate end of npm run arguments and then you can add the additional arguments.

$ npm run COMMAND -- OPTIONS

For example, if you run these commands:

$ npm run lint
$ npm run lint -- --fix

Then you’ll get these respectively:

$ eslint .
$ eslint . --fix

Though, I prefer to set up npm run lint:fix as a separate script command so run the --fix command for me.