title: MissingSchemaError: Schema hasn't been registered for model "User"
body: <p>In my <code>models/user.js</code> file:</p>
  
  <pre><code>var mongoose = require('mongoose');
  var Schema = mongoose.Schema;
  
  var userSchema = new Schema({
      (define schema)
  });
  ...
  (save user)
  ...
  (check password)
  ...
  mongoose.model('User', userSchema);
  </code></pre>
  
  <p>And in my <code>router/index.js</code>, I have:</p>
  
  <pre><code>var mongoose = require('mongoose');
  var User = mongoose.model('User');
  </code></pre>
  
  <p>which throws the error:</p>
  
  <pre><code>MissingSchemaError: Schema hasn't been registered for model "User".
  </code></pre>
  
  <p>If however, in <code>user.js</code>, I do (in the last line)</p>
  
  <pre><code>module.exports = mongoose.model('User', userSchema);
  </code></pre>
  
  <p>and in <code>index.js</code> I do <code>var User = require('../models/User');</code>, then everything works.</p>
  
  <p>But it should not, because in <code>config/pass.js</code> I am doing <code>var User = mongoose.model('User');</code> and it's working flawlessly.</p>
  
  <p>The <code>require('../models/User');</code> syntax isn't working on Ubuntu, but is on my Mac.</p>
  
  <p>What should I do? How do I fix it? I have looked at tons of sample apps, including <a href="https://github.com/linnovate/mean/blob/master/app/controllers/users.js">MEAN</a> but nothing was really helpful.</p>