reactjsgithubpackage.jsonjson-serverconcurrently

Run two scripts from package.json in Netifly


I have deployed my React app successfully in Netifly. My app live URL

Here is my package.json file's scripts:

  "scripts": {
    "start": "react-scripts start",
    "json-server": "json-server --watch db.json --port 3003",
    "start:dev": "concurrently \"npm start\" \"npm run json-server\"",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }

But the problem is: the site unable to show any kind of data. Please visit to have an idea. Because, json-server as backend serves db.json. It's not running in production.

Locally i can run yarn start:dev but couldn't able to run both scripts concurrently. What will be the proper scripts to run both react-scripts start && json-server --watch db.json --port 3003 in production?


Solution

  • I found myself the solution: "start": "concurrently \"react-scripts start\" \"npm run json-server\"", by updating solves the problem.