Typeerror: Database Is Not A Constructor When Initializing Constructor
I have a Database object (database.js) that looks like this: //create the database function Database(host, dbuser, dbpassword){ this.host = host; this.dbuser = dbuser;
Solution 1:
To export your Database
"class"
use
module.exports = Database;
And to use
varDatabase = require('./database.js');
newDatabase(...);
Here you have a good tutorial about how to use export/require
Is still strongly recommend to upgrade to ES6.
Post a Comment for "Typeerror: Database Is Not A Constructor When Initializing Constructor"