title: Node JS Require throw AssertionError: missing path
body: <p>I have a simple application written in node.js:</p>
  
  <pre><code>var mongo   = require('./helpers/mongo_utils.js');
  var express = require('express');
  var user = require('./models/users.js');
  
  mongo.connect(function (err)
  {
    if (err) throw err;
    console.log('connected');
  
    var app = express();
    app.listen(3000, function ()
      {
        console.log('Server set up and start listening on port 3000');
      })
  })
  </code></pre>
  
  <p>All works except when I require the users.js file. If I don't require it I have no problem, but when I do it I get this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>assert.js:89
    throw new assert.AssertionError({
    ^
  AssertionError: missing path
      at Module.require (module.js:363:3)
      at require (module.js:384:17)
      at Object.&lt;anonymous&gt; (/home/jimzer--jimzer/www/NodeJsForum/models/users.js:1:79)
      at Module._compile (module.js:434:26)
      at Object.Module._extensions..js (module.js:452:10)
      at Module.load (module.js:355:32)
      at Function.Module._load (module.js:310:12)
      at Module.require (module.js:365:17)
      at require (module.js:384:17)
      at Object.&lt;anonymous&gt; (/home/jimzer--jimzer/www/NodeJsForum/app.js:3:12)
  </code></pre>
  
  <p>Here is the code of users.js if it can help:</p>
  
  <pre><code>var mongo     = require('') = ('./../helpers/mongo_utils.js');
  var mailValid = require('./../helpers/email_valid.js');
  
  var db = mongo.getDb();
  
  var User = function (pseudo, psw, mail, level, callback)
  {
    // Params checking
    if (!(pseudo &amp;&amp; psw &amp;&amp; mail &amp;&amp; (level != 'undefined')))
    {
      err = new Error("All fields aren't specified"); err.code = 0;
      return callback(err);
    }
    // Mail validation
    if (!mailValid(mail))
    {
      err = new Error("Mail adress isn't valid"); err.code = 1;
      return callback(err);
    }
    db.users.findOne({mail: mail}, function (err, doc)
    {
      if (err) throw err;
      if (doc)
      {
        err = new Error("Mail adress already used");
        err.code = 1;
        return callback(err);
      }
    });
  
    // Pseudo
    if (!(pseudo.length &gt; 0 &amp;&amp; pseudo.length &lt; 20))
    {
      err = new Error("Pseudo length invalid");
      err.code = 2;
      return callback(err);
    }
    db.getDb.users.findOne({_id: pseudo}, function (err, doc)
    {
      if (err) throw err;
      if (doc)
      {
        err = new Error("pseudo déja utilisé"); err.code = 2;
        return callback(err);
      }
    });
  
    // Psw validation
    if (!(psw instanceof String))
    {
      err = new Error("Password invalid"); err.code = 3;
      return callback(err);
    }
  
    // Level validation
    if (!(lvl &gt; 0 &amp;&amp; lvl &lt; 10))
    {
      err = new Error("Access level invalid"); err.code = 4;
      return callback(err);
    }
  
    // If all test are OK, we construct and instance of User and pass it to the callback
    else
    {
      this.pseudo = pseudo;
      this.psw = psw;
      this.mail = mail;
      this.date = Date.now();
      this.lvl = lvl;
      return callback(null, this);
    }
  }
  
  module.exports = User;
  </code></pre>