Maria Jane Maria Jane - 4 months ago 8
Node.js Question

Strange node.js error trying to start express app

I can start my app using nodemon, just by typing

nodemon


but got below error when I do
node app.js


enter image description here

My package.json is configured properly. It has

"scripts": {
"start": "node ./bin/www"
}

Answer

The port is already in use, there might be another instance of your application already running. To see what processes are running background use netstat -tlpn and to filter node only processes netstat -tlpn | grep node.

tcp        0      0 127.0.0.1:8081          0.0.0.0:*               LISTEN      22917/node          
tcp        0      0 127.0.0.1:8666          0.0.0.0:*               LISTEN      358/node            
tcp        0      0 127.0.0.1:8667          0.0.0.0:*               LISTEN      4416/node  

As you see the port 8081 is already taken, try to kill it and start you server again kill 22917.