In my models/user.js file:
var mongoose = require(\'mongoose\');
var Schema = mongoose.Schema;
var userSchema = new Schema({
(define schema
I got this error while trying to use mongoose-fixture to seed some default data into a mongo collection. Was baffled for long, following this and similar threads for help, trying to debug. Ultimately the issue turned out to be due to mongoose and mongoose-fixture versions in my case.
If no code changes help, or if you get this error while trying to correctly use mongoose-fixture (which is supposed to register your schemas for you), try this. Delete the node_modules dir of your project, run an npm cache clean, and then an npm install.
If even this doesn't help, try comparing versions of mongoose / mongoose-fixture between the problematic app and one that works, and try changing the version in your package.json, and repeating the above steps. This worked for me.