0

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();

1 Answer 1

2

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.