This is a very common error, when you start your server with Nodemon, you might face this error. So, what comes? and What is the solution? Let’s get started.
Error:
Solutions (with reason)
First
Maybe your PC running several processes in the Background. So you need to stop all the node process that are running.
Quick trick
Kill them all by running this on terminal:
pkill -f node
or to kill a particular port instead of all
sudo lsof -i :3000 //replace 3000 with your port number
sudo kill -9 31363 // replace 31363 with your PID
and then restart Nodemon.
Second
Server.js and package.json are not in the same folder.
check package.json
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon Server.js"
}
Third
You have written the wrong code in any of the files. So for that make sure you didn’t miss any JS syntax. If you did the wrong code, here I’m talking about syntax error (not logic), then your Nodemon will not start.
Hope you will get the resolutions.