Node JS : “Not a Constructor” Exception while creating objects

65 Views Asked by At

I have defined a class like this (usage.js):

Does not work

  module.exports = class abc {
     constructor() {
    }}

But if I export the below way it works

Working

class abc {
constructor() {
}}

module.exports = abc;

Usage of class in file calling.js

const abc = require('./usage');
let abcinstance = new abc() -- Error - abc is not a contructor

What is wrong in the first way ?

0

There are 0 best solutions below