1

I'm trying to attach another command to yarn start. I'm not sure if it is possible but when I run command yarn start I want my react app to start and I also want to fire up my server at the same time.

What I do know is use 2 terminals one with react app directory and call on yarn start

C:\Users\ivanr\Documents\GitHub\bees\business-scheduler>

and one with server directory (which is inside react app directory) and call on node src/index.js

C:\Users\ivanr\Documents\GitHub\bees\business-scheduler\server>
  "scripts": {
    "start": "react-scripts start", // is it possible that I can say in server directory run node src/index.js here?
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

2 Answers 2

4

You can use concurrently

First install it

$ npm install concurrently

Then use it in your command

"scripts": {
  "start": "concurrently \"yarn start-client\" \"yarn start-server\"",
  "start-client": "react-scripts start",
  "start-server": "cd .\server && node src/index.js"
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you this was exactly the kind of structure I was looking for but didn't find
0

You can use npm-run-all

"scripts": {
    "clean": "rimraf dist",
    "lint":  "eslint src",
    "build": "babel src -o lib"
}

npm-run-all clean lint build

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.