node events.js:136 throw er; Unhandled 'error' event

Viewed 7757

I am getting events.js:136 throw er; Unhandled 'error' event don't know how and why? i have reinstalled the nodejs and mongodb as well but throwing same error.

package.json

{
"name": "bookstore",
"version": "1.0.0",
"description": "simple bookstore app",
"main": "app.js",
"devDependencies": {},
"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
    "express": "*",
    "body-parser": "*",
    "mongoose": "*"
},
"author": "AveesP",
"license": "ISC"

}

App.js code

var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
//connect to mongoose
mongoose.connect('mongodb://localhost/bookstore');
var db = mongoose.connection;
app.get('/', function(req, res) {
   res.send('Hello world!');
});
app.listen(3000);
console.log('Running on port 3000...');

enter image description here

3 Answers

I have got that root cause.. i have not made any database using mongodb its a connection error..

thanks Mark for your time.

Related