i have this class called DocumentReader in a "/lib/DocumentReader.js" i tried to export it using module.exports = DocumentReader;
and i have another file called main.js
that i'm trying to use this file in it but when ever i do this
var doc = require("./lib/DocumentReader.js");
var docr = new DocumentReader("");
i get this error ReferenceError: DocumentReader is not defined
this is the class in DocumentReader.js
var fs = require("fs");
class DocumentReader{
constructor (filepath){
this.filepath = filepath;
}
readfile(){
fs.readFile(this.filepath,function(err,data){
if(err) throw err;
console.log(data);
});
}
}
i tried looking for similiar errors or cases like this but i didn't find them
when i print the value of doc
i get this [Function: DocumentReader]