node.jsreactjsexpress

How to run Front End and Backend together in React.js and Express.js


I have written a program with React and Express to run in development mode with servers separately, is it possible to run simultaneously, and my other question is how it is possible in build mode

Thankful


Solution

  • Like Adrian mentioned in the comment, you can use concurrently

    But require a certain folder structure, in order to run server and client simultaneously

    You can try this structure: enter image description here

    In the package.json file, edit the script:

      "scripts": {
        "server": "npm run dev --prefix server",
        "client": "npm start --prefix client",
        "dev": "concurrently \"npm run server\" \"npm run client\""
      },
    

    And, npm run dev you can start both at the same time.