To run multiple commands in package.json with JavaScript, we use &&
to separate the commands.
For instance, in package.json, we write
{
"scripts": {
"init-assets": "webpack",
"init-server": "node server/server.js",
"start": "npm run init-assets && npm run init-server"
}
}
to add the start
script that runs the npm run init-assets
and npm run init-server
commands.
init-assets
and init-server
are the scripts added before start
.