I have a problem with node.js. I am creating a blog and I have two 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 is not a function
TypeError: object is not a function
require
returns the exports
object, so:
var SessionsDAO = require('./sessions').SessionsDAO;
var s = new SessionsDAO();
s.startSession(username);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.