Node.js <Class> is not a constructor

I got this error when calling new ClassName(); and it was caused in the ClassName class by missing off the "module." from module.exports = ClassName

Just in case someone else is as daft as me...


When you assigned this:

exports.HttpHandlers = HttpHandlers;

You would need to match that with this:

var HttpHandlers = require('../lib/restifyHandlers/HttpHandlers').HttpHandlers;

You are assigning a property of your module to be .HttpHandlers, not assigning the whole module so if you want that property, you have to reference the property. If you want it to work the other way, you could change to this:

exports = HttpHandlers;

And, then your require() could work the way you are doing it like this:

var HttpHandlers = require('../lib/restifyHandlers/HttpHandlers');