In my models/user.js
file:
var mongoose = require(\'mongoose\');
var Schema = mongoose.Schema;
var userSchema = new Schema({
(define schema
I got the same problem when I am trying the MEAN tutorial.
After done a little bit research, I found that in app.js, if I put require("./models/User") before var routes = require("./routes/index"), then it works.
Like this:
mongoose.connect("mongodb://localhost/news");
require("./models/Posts");
require("./models/Comments");
var routes = require('./routes/index');
var users = require('./routes/users');
var app = express();
Hope the answer will be helpful!