Search code examples
reactjscreate-react-appjson-server

Run two npm commands concurrently


I've setup json-server and runs successfully on port-3000 then run npm start it runs on other port 3001.

But I want to run both concurrently. I tried with Concurrently but didn't work.

When I execute this command :

$ concurrently "npm start" "json-server --watch ./topPanelData.json"

Error message:

Error message


Solution

  • Resolved issue with these steps:

    1. Create json-server.json with the following key to run a server on a different port.

      { "port": 4000 }

    2. Update start script in package.json

      "start": "concurrently \"react-scripts start\" \"json-server ./topPanelData.json\""

    3. simply run $ npm start It'll concurrently execute both on the different port

      json-server: http://localhost:4000/topPanelData

      React app: http://localhost:3000/