Reputation: 2324
I am trying to create an object from the required file Account.js. Node.js displays an error on line var test = new account();
: Account is not defined. What am I doing wrong here?
// Account.js
module.exports = function Account() {
console.log("THIS SHOULD WORK");
}
// app.js
require('./Account');
var test = new Account();
Upvotes: 0
Views: 254
Reputation: 6477
Please note that require isn't like import
or include
. This is what you're missing:
// app.js
var Account = require('./Account');
var test = new Account();
Upvotes: 2