Start react-create-app and Electron.js with one NPM command - node.js

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 ?

Consider utilizing concurrently.
cd to your project directory and run the following command to install it:
npm i -D concurrently
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\""

Related

React App's npm i is Hanging on Installation

So, I've tried running npm i on my React app so that I can work concurrently on both front and back end at the same time. However, it seems to be hanging on the "install":
appName#0.1.0 install
cd server && npm i && cd ../client && npm i
Below are the package.json scripts I'm using:
"scripts": {
"start": "node server/server.js",
"dev": "concurrently \"cd server && npm run watch\" \"cd client && npm start\"",
"install": "cd server && npm i && cd ../client && npm i",
"build": "cd client && npm run build",
"seed": "cd server && npm run seed",
"test": "echo \"Error: no test specified.\" && exit 1",
"eject": "react-scripts eject"
},
What am I doing wrong? Any help is greatly appreciated!
You may be running into an infinite loop since you have defined an install script in your package.json. For more details on npm scripts configuration have a look here.
You might also be facing similar issues with some of the other scripts you have defined, e.g. build also calls itself npm run build. You should build the project code as part of the build script. See the CRA source build script for reference: https://github.com/facebook/create-react-app/blob/d960b9e38c062584ff6cfb1a70e1512509a966e7/package.json#L8
Try removing the install script and run the commands manually when you need to install dependencies for your project. The updated scripts:
"scripts": {
"start": "node server/server.js",
"dev": "concurrently \"cd server && npm run watch\" \"cd client && npm start",
"build": "cd client && npm run build",
"seed": "cd server && npm run seed",
"test": "echo \"Error: no test specified\" && exit 1",
"eject": "react-scripts eject"
},
As a side note/question, why don't you run npm i from the root of the project and then run your build and seed commands?
Only installing dependencies will not build your app, in most cases.

AWS Beanstalk Node js deployment issue

Hi I am trying to deploy node js app on AWS Elastic Beanstalk. However I am not able to deploy the same. Every-time the build fails.
Getting below error:
During an aborted deployment, some instances may have deployed the new application version. To ensure all instances are running the same version, re-deploy the appropriate application version.
Sharing part of package.json for reference.
"scripts": {
"start": "node server.js",
"server": "nodemon server",
"client": "npm start --prefix client",
"debug": "ndb server.js",
"dev": "concurrently \"npm run server\" \"npm run client\"",
"test": "mocha --recursive --timeout 20000 --exit",
"heroku-postbuild": "cd client && NPM_CONFIG_PRODUCTION=false npm install && npm run build"
},

how to configure "npm run-script build" command in Nodejs package.json

I am trying to deploy nextjs based project on AWS EBS, but it is not able to run script "npm run-script build" on server, by this it makes nextjs based build package folder and can run app. here my json.
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "cross-env NODE_ENV=production node server.js"
}
when I deployed my app on server it gives following error.
Error: Could not find a valid build in the '/var/app/current/.next' directory! Try building your app with 'next build' before starting the
server.
I need to run command "npm run-script build" before running app on server, but dosen't aware how to achieve this
simply we can run multiple commands at a time.
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "npm-run-script-build && cross-env NODE_ENV=production node server.js"
}

NPM command for run Node server after webpack finish building

I want to run a command like: npm run start:dev to make my node server runs but after webpack finished building bundles.
My current npm scripts are:
"scripts": {
"start": "node server/server.js",
"start:dev": "npm run build:prod & npm start",
"lint": "eslint *",
"build:dev": "webpack",
"build:prod": "webpack -p --env production",
"dev-server": "webpack-dev-server",
"test": "cross-env NODE_ENV=test jest --config=jest.config.json"
},
The current command will kick both operations together.
Typo: you don't actually want to use &, you want &&:
"start:dev": "npm run build:prod && npm start",
A single ampersand will background the run:build job and cause start to run concurrently.

Run npm build after beanstalk deploy

Anyone know how to get node AWS beanstalk to run npm run build command after its does its npm install.
I have the following scripts in my package.json but it doesn't seem to run the build or the start command just the install
"scripts": {
"build": "cross-env NODE_ENV=production webpack --config ./webpack/webpack.prod.config.js --progress --colors",
"start": "node server/app.js",
"dev": "nodemon server/app.js"
},

Resources