Reputation: 1311
I'm trying to start a json-server and start my React-App in the same script in package.json ...
But the problem is that none of the two scripts give me the prompt back so the second script is never launched ...
I've tried :
"scripts": {
"start": "npm run start-db & npm start-react",
"start-react": "react-scripts start && exit 1",
"start-db": "json-server --watch src/bdd.json -p 3001 && exit 1"
}
with differents combinations of &&
or &
... With or without exit 1
( things that I found here )
Upvotes: 1
Views: 637
Reputation: 2277
you can use a tool like concurrently.
"scripts": {
"start": "concurrently \"npm:start-db\" \"npm:start-react\"",
"start-react": "react-scripts start",
"start-db": "json-server --watch src/bdd.json -p 3001"
}
after installing it with npm i --save-dev concurrently
.
Upvotes: 0
Reputation: 5912
you can pass multiple commands like this
npm run start-db start-react
Upvotes: 1