I am having an issue with Node.js and module.exports
. I understand that module.exports
is a call to return an object, that object having whatever p
Try this:
module formatting:
function Format() {
this.setter = function(text) {
this.text = text;
}
this.show = function() {
console.log(this.text);
}
}
//this says I want to return empty object of Format type created by Format constructor.
module.exports = new Format();
index.js
var formatting = require('./formatting');
formatting('Welcome');
console.log(formatting.show());