Categories
JavaScript Answers

How to run multiple commands in package.json with JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *