Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yarn run multiple scripts in parallel

Tags:

npm

yarnpkg

I'm migrating from NPM to Yarn, and I want to run scripts in parallel such as:

npm-run-all --parallel script1 script2 script3

What is its equivalent in Yarn?

What I found as its equivalent is to run each separately:

yarn run script1 && yarn run script2 && yarn run script3

but I can't run scripts in parallel.

how to use multiple scripts & in parallel?

like image 991
belhadj haythem Avatar asked Sep 03 '18 14:09

belhadj haythem


People also ask

Does yarn run parallel?

“yarn run commands in parallel” Code Answer's js, but you can use it to run any commands.

Can the npm run all CLI tool run multiple npm scripts in parallel?

The official npm run-script command cannot run multiple scripts, so if we want to run multiple scripts, it's redundant a bit. Let's shorten it by glob-like patterns. Cross platform. We sometimes use & to run multiple command in parallel, but cmd.exe ( npm run-script uses it by default) does not support the & .

How do I run multiple commands in node JS?

After running npm i concurrently to install it, you can then set up your NPM start script to run multiple commands just by separating each individual command with quotes. And once again, you should be off to the races.


2 Answers

There is a difference between using & and &&. Using & will run scripts in parallel, using && will run scripts one after the other.

package.json:

{
    "parallel": "yarn script1 & yarn script2",
    "serial": "yarn script1 && yarn script2",
    "script1": "... some script here",
    "script2": "... some there script here"
}
like image 161
magikMaker Avatar answered Oct 21 '22 07:10

magikMaker


From what I read on documentation of npm-run-all, you can just keep using it, and, as long as you run the script with yarn it will use YARN to run scripts in parallel.

Here is the original quote from https://github.com/mysticatea/npm-run-all

Yarn Compatibility

If a script is invoked with Yarn, npm-run-all will correctly use Yarn to execute the plan's child scripts.

like image 16
raul Avatar answered Oct 21 '22 07:10

raul