I followed this question How to implement inheritance in node.js modules? but it didn't work for me.
// usermgmt.js
function Usermgmt() {
};
module.exports = Usermgmt;
// authentication.js
var Usermgmt = require('./usermgmt');
function Authentication() {
Authentication.super_.apply(this, arguments);
}
Authentication.super_ = Usermgmt;
Authentication.prototype = Object.create(Usermgmt.prototype, {
constructor: {
value: Authentication,
enumerable: false
}
});
Authentication.prototype.test = function() {
console.log("test");
};
module.exports = Authentication;
// index.js
var auth = new require('../modules/authentication');
auth.test();
i tryed it also with class but it didn't work. nodejs version 12 call method in another method I get the error TypeError: auth.test is not a function