javascript - Node JS Require throw AssertionError: missing path -


i'm stuck on problem few hours, cannot find out. i've simple application write in node js:

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 , start listening on port 3000');     }) }) 

all works except when require users.js file. if don't require have no problem, when got error:

assert.js:89   throw new assert.assertionerror({   ^ assertionerror: missing path     @ module.require (module.js:363:3)     @ require (module.js:384:17)     @ object.<anonymous> (/home/jimzer--jimzer/www/nodejsforum/models/users.js:1:79)     @ module._compile (module.js:434:26)     @ object.module._extensions..js (module.js:452:10)     @ module.load (module.js:355:32)     @ function.module._load (module.js:310:12)     @ module.require (module.js:365:17)     @ require (module.js:384:17)     @ object.<anonymous> (/home/jimzer--jimzer/www/nodejsforum/app.js:3:12) 

if can me wonderful !!

here code of users.js if can help:

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 && psw && mail && (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 used");       err.code = 1;       return callback(err);     }   });    // pseudo   if (!(pseudo.length > 0 && pseudo.length < 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 > 0 && lvl < 10))   {     err = new error("access level invalid"); err.code = 4;     return callback(err);   }    // if test ok, construct , instance of user , pass 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; 

read stacktrace:

at object.<anonymous> (/home/jimzer--jimzer/www/nodejsforum/models/users.js:1:79) 

this wrong:

var mongo     = require('') = ('./../helpers/mongo_utils.js'); 

not sure trying achieve, should instead:

var mongo     =  ('./../helpers/mongo_utils.js'); 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -