Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sequential NPM script after "react-scripts start"

Working on an Electron app with React. Right now, to get things started, I run the typical npm start command which runs the react-scripts start script.

This starts the dev server. Once the dev server is started, I open a second terminal window and run a script to start electron npm run start-electron which opens my React app in the Electron window.

This works as expected, but I was curious if there was a way to create a script that would:

  • Start the dev server
  • Wait for dev server to be started
  • Then start electron

I tried setting up a sequential script in package.json but it only starts up the dev server. For example npm run start && npm run start-electron.

This isn't make or break. The two terminal option works fine, just didn't know if this was possible.

like image 670
Andrew Avatar asked Nov 01 '25 19:11

Andrew


1 Answers

Yes it is possible, I use concurrently to do it within my projects

npm i concurrently

and add a new script, let's call it dev for example, then in your scripts:

"dev": "concurrently \"npm run start\" \"npm run start-electron\""

All that remains to do now is npm run dev

like image 72
Slim Avatar answered Nov 03 '25 12:11

Slim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!