2
votes

I have simple custom starter pack react-create-app and Electron.js. I have added to package.json file:

"scripts": {
    "electron": "electron .",
    "start": "cross-env BROWSER=none react-scripts start",
....

and I can start Electron with npm run electron and React with - npm start.

What I want is to start React and Electron just with one command like: npm run both.

I have tried:

"both": "\"npm start\" \"npm run electron \"", 

but I am getting an error in a log file:

Exit status 1 node_modules\npm\node_modules\npm-lifecycle\index.js:301:16) - nothing specific

I have tried and:

    "start": "npm run electron . && cross-env BROWSER=none react-scripts start",

, but this starts the Electron, when I close it, it start the React app.

Again error:

"electron": "electron .",
"start": "cross-env BROWSER=none react-scripts start",
"both": "\"npm run electron\" \"npm run start\"",

I don't know, how to start react-create-app and Electron with just one NPM command ?

1

1 Answers

3
votes

Consider utilizing concurrently.

  1. cd to your project directory and run the following command to install it:

    npm i -D concurrently
    
  2. Then redefine the both script in the scripts section of your package.json as follows:

    "both": "concurrently \"npm start\" \"npm run electron\""
    

    or the slightly shortened equivalent:

    "both": "concurrently \"npm:start\" \"npm:electron\""