Hello,
I'd like to load a file (as string content) located in the same directory as the module:
module/test.txt
module/index.js
index.js content:
var fs = require('fs');
function load(){
fs.readFile('./test.txt', 'utf8', function(err, data) {
//this is not working, probably because fs is looking in app working directory
}
}
exports.load=load;
Is there a surefire way to get the contents of test.txt? I tried require('test.txt') but that throws an error since test.txt does not contain javascript.
I would appreciate any help in this matter.
Thanks,
M