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

Upvotes: 1

Views: 2080

Answers (2)

user16779013
user16779013

Reputation:

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

Upvotes: 1

3ndless_____
3ndless_____

Reputation: 159

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

Upvotes: 0

Related Questions