javascript - node.js export module function -


i have problem node.js. creating blog , have 2 archives: sessions.js users.js

in sessions.js :

function sessionsdao(db) { this.startsession = function(username, callback) {....} } module.exports.sessionsdao = sessionsdao; 

in users.js

var session = require('./sessions'); var s = new session(); s.startsession(username); 

but shows me error:

object not function typeerror: object not function 

require returns exports object, so:

var sessionsdao = require('./sessions').sessionsdao; var s = new sessionsdao(); s.startsession(username); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -