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

Time:04-04

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

CodePudding user response:

Nodemon has nothing to do with the client-side(React app). So, before running npm-start:

  1. Make sure you are in the correct directory cd [directory-name]
  2. It's better to separate your front-end and back-end in a separate folder

CodePudding user response:

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

  • Related