What is colon : in npm script names?
I believe it's just a naming convention to group a set of related tasks. For example you might have
"test:ci": ..."test:units": ...."test:integration"...
In this case it is grouping a related set of test tasks.
It would be down to the package author to specify. You can split tasks out like described in the answer above and then have a 'global' test
command which combines each of them e.g. test:ci && test:unit && test:integration
enabling you to run them all at once or when individually when needed.
You can use npm-run-all
(link) and use the command npm-run-all test:*
, which would then find all scripts starting with the test:
group.
I solved this by running - "npm run <scriptName>"
Within my package.json
file, I had two "start scripts"
start
: nodemon server.js
start:elasticsearch
: docker run elasticsearch..
Solved with npm run start:elasticsearch
If using Yarn package manager, you can use a colon in the name to call the script from any workspace.
According to the yarn docs on How to share scripts between workspaces?:
Little-known Yarn feature: any script with a colon in its name (
build:foo
) can be called from any workspace.
Also, according to yarn docs on CLI > run:
Otherwise, if the specified name contains a colon character and if one of the workspaces in the project contains exactly one script with a matching name, then this script will get executed.