parallelshell vs concurrently vs npm-run vs npm-run-all
NPM Script Management Tools
parallelshellconcurrentlynpm-runnpm-run-allSimilar Packages:

NPM Script Management Tools

NPM script management tools are utilities that help developers run multiple npm scripts concurrently or sequentially. These tools are particularly useful in complex projects where tasks like building, testing, and deploying need to be automated efficiently. They provide features like running scripts in parallel, handling dependencies between tasks, and improving the overall workflow in a development environment. These tools help streamline the execution of multiple scripts, making the development process more efficient and organized. concurrently is a tool that allows you to run multiple commands concurrently, displaying their output in a single terminal. It is simple to use and is ideal for running tasks like starting a server and a client simultaneously. npm-run is a lightweight utility for running npm scripts programmatically. It is useful for automating tasks within Node.js applications but does not provide features for running multiple scripts concurrently. npm-run-all is a CLI tool that allows you to run multiple npm scripts sequentially or concurrently. It provides more control over the execution order of scripts and is useful for complex workflows that require running tasks in a specific sequence or in parallel. parallelshell is a tool for running multiple shell commands in parallel. It is similar to concurrently but focuses on running shell commands rather than npm scripts. It is useful for tasks that require running multiple commands simultaneously, such as building multiple projects or running tests in parallel.

Npm Package Weekly Downloads Trend

3 Years

Github Stars Ranking

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
parallelshell9,689498-209 years agoMIT
concurrently07,812411 kB58a month agoMIT
npm-run0187-68 years agoMIT
npm-run-all05,837-1148 years agoMIT

Feature Comparison: parallelshell vs concurrently vs npm-run vs npm-run-all

Concurrency

  • parallelshell:

    parallelshell allows you to run multiple shell commands in parallel. It is similar to concurrently but focuses on shell commands rather than npm scripts.

  • concurrently:

    concurrently allows you to run multiple commands or scripts at the same time, displaying their output in a single terminal. It is designed specifically for running tasks concurrently and provides features like color-coded output to distinguish between commands.

  • npm-run:

    npm-run does not support running multiple scripts concurrently. It is designed for running a single npm script programmatically.

  • npm-run-all:

    npm-run-all supports running multiple npm scripts either sequentially or concurrently. It provides more flexibility in how scripts are executed, allowing you to choose the mode that best fits your workflow.

Script Management

  • parallelshell:

    parallelshell does not provide features for managing the execution order of commands. It simply runs all specified commands in parallel.

  • concurrently:

    concurrently is focused on running multiple commands or scripts concurrently but does not provide features for managing the execution order or dependencies between scripts.

  • npm-run:

    npm-run is a simple tool for running a single npm script programmatically. It does not provide features for managing multiple scripts or their execution order.

  • npm-run-all:

    npm-run-all provides features for managing the execution order of multiple npm scripts. You can run scripts sequentially, concurrently, or a combination of both, making it ideal for complex workflows.

Output Handling

  • parallelshell:

    parallelshell does not provide any special output handling. The output from all commands is combined, which can make it difficult to distinguish between them.

  • concurrently:

    concurrently provides color-coded output for each command, making it easy to distinguish between the outputs of different scripts. This is particularly useful when running multiple tasks simultaneously.

  • npm-run:

    npm-run does not provide any special output handling. It simply runs the specified npm script and outputs the result to the console.

  • npm-run-all:

    npm-run-all does not provide specialized output handling for concurrent scripts. The output from all scripts is combined, which can make it harder to distinguish between them when running scripts concurrently.

Ease of Use

  • parallelshell:

    parallelshell is straightforward to use for running multiple shell commands in parallel. It requires minimal setup and is easy to integrate into existing workflows.

  • concurrently:

    concurrently is easy to use and requires minimal configuration. You can run multiple commands with a single command, and the color-coded output makes it easy to understand what is happening.

  • npm-run:

    npm-run is simple to use for running a single npm script programmatically. It is lightweight and does not require much setup.

  • npm-run-all:

    npm-run-all is easy to use for running multiple scripts, but it may require some configuration to set up complex workflows. The documentation is clear, and it provides examples for common use cases.

Code Examples

  • parallelshell:

    Running multiple shell commands in parallel with parallelshell

    "scripts": {
      "build-css": "node-sass src/styles -o dist/styles",
      "build-js": "babel src -d dist",
      "build": "parallelshell \"npm run build-css\" \"npm run build-js\""
    }
    
  • concurrently:

    Running multiple commands concurrently with concurrently

    "scripts": {
      "start-server": "node server.js",
      "start-client": "npm start --prefix client",
      "start": "concurrently \"npm run start-server\" \"npm run start-client\""
    }
    
  • npm-run:

    Running a single npm script programmatically with npm-run

    const npmRun = require('npm-run');
    npmRun('build', (err, stdout, stderr) => {
      if (err) {
        console.error('Error running build script:', err);
        return;
      }
      console.log('Build script output:', stdout);
    });
    
  • npm-run-all:

    Running multiple npm scripts sequentially or concurrently with npm-run-all

    "scripts": {
      "clean": "rimraf dist",
      "build": "webpack",
      "test": "jest",
      "build-all": "npm-run-all clean build test",
      "build-concurrent": "npm-run-all --parallel clean build test"
    }
    

How to Choose: parallelshell vs concurrently vs npm-run vs npm-run-all

  • parallelshell:

    Choose parallelshell if you need to run multiple shell commands in parallel from the command line. It is simple and effective for running multiple commands simultaneously, but it does not provide features specific to npm scripts.

  • concurrently:

    Choose concurrently if you need a simple and effective way to run multiple commands or scripts at the same time, especially for tasks like running a frontend and backend server simultaneously. It is user-friendly and provides clear output for each command.

  • npm-run:

    Choose npm-run if you need a programmatic way to run npm scripts within your Node.js application. It is lightweight and ideal for automating tasks without the need for running multiple scripts concurrently.

  • npm-run-all:

    Choose npm-run-all if you need to run multiple npm scripts either sequentially or concurrently with more control over the execution order. It is ideal for complex workflows that require running tasks in a specific sequence or in parallel.

README for parallelshell

Parallel Shell

This is a super simple npm module to run shell commands in parallel. All processes will share the same stdout/stderr, and if any command exits with a non-zero exit status, the rest are stopped and the exit code carries through.

Version compatibility notes

  • Fully compatible with Node up to v8 and later!

Maintenance has been resumed by @darkguy2008. However, there are also better options, see Consolidation of multiple similar libraries.

Motivation

How is this different than:

$ cmd1 & cmd2 & cmd3
  • Cross platform -- works on Unix or Windows.

  • & creates a background process, which only exits if you kill it or it ends. parallelshell will autokill processes if one of the others dies.

  • command1 & command2 & command3 will wait in the terminal until command3 ends only. parallelshell will wait until all 3 end.

  • If command1 or command2 exit with non-zero exit code, then this will not effect the outcome of your shell (i.e. they can fail and npm/bash/whatever will ignore it). parallelshell will not ignore it, and will exit with the first non-zero exit code.

  • Pressing Ctrl+C will exit command3 but not 1 or 2. parallelshell will exit all 3

  • parallelshell outputs all jobs stdout/err to its stdout/err. background jobs do that... kind of coincidentally (read: unreliably)

So what's the difference between GNU parallel and this?

The biggest difference is that parallelshell is an npm module and GNU parallel isn't. While they probably do similar things, albeit (GNU) parallel being more advanced, parallelshell is an easier option to work with when using npm (because it's an npm module).

If you have GNU parallel installed on all the machines you project will be on, then by all means use it! :)

Install

Simply run the following to install this to your project:

npm i --save-dev parallelshell

Or, to install it globally, run:

npm i -g parallelshell

Usage

To use the command, simply call it with a set of strings - which correspond to shell arguments, for example:

parallelshell "echo 1" "echo 2" "echo 3"

This will execute the commands echo 1 echo 2 and echo 3 simultaneously.

Note that on Windows, you need to use double-quotes to avoid confusing the argument parser.

Available options:

-h, --help         output usage information
-v, --verbose      verbose logging
-w, --wait         will not close sibling processes on error