I am following the Thinkster MEAN Stack tutorial and am stuck at the Testing the Initial Routes section in which, after I have already started the MongoDB using the command "mongod &" I still get this error when I npm start...
/Users/myname/workspace/mean_projects/flappernews/node_modules/mongodb/lib/server.js:236
process.nextTick(function() { throw err; })
Now it seems as though that this error generally occurs when MongoDB is not started or not connected but I have used the
mongod &
command in my terminal like the tutorial suggested. How do I make sure that my app is connected to my local database on npm start and get past this error.
Here is how I setup the top portion of my app.js
var mongoose = require('mongoose');
require('./models/Posts');
require('./models/Comments');
mongoose.connect('mongodb://localhost/news');
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
...
I believe the "mongoose.connect('mongodb://localhost/news');" part is what is giving me the error.