When you are working on a Node project, you might want to run some tasks in parallel. Fortunately, there is a package for that: npm-run-all.

npm-run-all contains three commands:

  • npm-run-all - You can run this command by passing the following arguments: npm-run-all -p to run commands in parallel; npm-run-all -s to run commands sequentially.
  • run -p - Shorthand to run commands in parallel.
  • run -s - Shorthand to run command sequentially.

For example, in order to start your development server you might need to have two commands, one for the frontend server and one for the backend server. Instead of having to start them individually, you can run them in parallel. Let’s install npm-run-all and run the servers in parallel using the example above:

  1. Install npm-run-all by typing at the command prompt: npm install npm-run-all --save-dev or yarn add npm-run-all --dev.

  2. In your package.json file under the scripts section, we have a frontend command to run a React application (start:client) and a backend server that is built with Node (start:server). In order to run both of them in parallel, we would type the following in the start command:

        "scripts": {
            "start": "run-p start:client start:server",
            "start:client": "react-scripts start",
            "start:server": "node src/api/apiServer.js"
  3. Save the changes in the file and then type npm run start or yarn run start and both of the servers should be running.