Search code examples
node.jsreactjsnpmnodemonnpm-start

npm start is starting the server.js not my React app, how can I use it to start my app?


So I was having this issue of node not restarting the server when there changes made on the server.js file. I fixed it by editing the package.json file. However, once fixed, the npm start command starts the server.js file: [nodemon] starting `node server.js

How do I start my react app then? npm start was the command I used before


Solution

  • Most probably your set your package.json file to

    "scripts": {
    "start": "nodemon server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
    

    },

    Change your server package.json to something like this:

     "scripts": {
    "server": "nodemon server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
    

    then run the command

    npm run server --this will start your server.js