Trying to figure out what putting : in an npm script name does. For example:
package.json
"test:ci": "rest of script"
what would :ci
do? running npm run test:ci
fails
I can't find anything bash syntax really.
An npm script is a convenient way to bundle common shell commands for your project. They are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application. Scripts are stored in a project's package.
Listing the scripts available in a package. json file is easy: just go to the root directory of your project and type npm run in the terminal. Then run the ntl command in the project folder. You'll get a list of available scripts, with the option of selecting one of them to run.
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 you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With