require() throw “AssertionError: missing path” - Node js
<p>I am trying out a simple nodejs application.All works fine until i separate db model into user file and requiring it in the routes.js.Then it gives out a “AssertionError: missing path” error when i try to run the server.</p>

<p><strong>routes.js</strong> (path='demo/app/routes.js')</p>

<pre><code>var User=require('./models/user');

module.exports=function(app){
    app.get('/',function(req,res){
        res.send("hello world");
    });

    app.get('/:username/:password',function(req,res){
        var newUser =new User();
        newUser.local.username=req.params.username;
        newUser.local.password=req.params.password;
        console.log(newUser.local.username);
        newUser.save(function(err){
            if(err){
                throw err;
            }
        });
        res.send('success');
    });
}
</code></pre>

<p><strong>user.js</strong> (path='demo/app/models/user.js')</p>

<pre><code>var mongoose=require(mongoose);

var userScheme=mongoose.Schema({
    local:{
        username:String,
        password:String
    }
});

module.exports=mongoose.model('User',userScheme);
</code></pre>

<p><strong>server.js</strong> running file (demo/server.js)</p>

<pre><code>var express=require('express');
var app=express();
var port =process.env.PORT||3000;

var morgan=require('morgan');
var cookieParser=require('cookie-parser');
var session=require('express-session');
var mongoose=require('mongoose');

var configDB=require('./config/database.js');
mongoose.connect(configDB.url);

app.use(morgan('dev'));
app.use(cookieParser());
app.use(session({
    secret:'pokemonGo',
    saveUninitialized:true,
    resave:true
}));

require('./app/routes.js')(app);

app.listen(port);
console.log('server running ');
</code></pre>

<p><strong>and the error says</strong></p>

<pre><code>assert.js:90
  throw new assert.AssertionError({
  ^
AssertionError: missing path
    at Module.require (module.js:351:3)
    at require (internal/module.js:12:17)
    at Object.&lt;anonymous&gt; (/Users/menaka/WebstormProjects/cardCreaterServer/app/models/user.js:4:14)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.&lt;anonymous&gt; (/Users/menaka/WebstormProjects/cardCreaterServer/app/routes.js:4:10)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
</code></pre>