this is my simple code.
const fs = require('fs');
try {
const data = fs.readFileSync('file.txt', 'utf8');
console.log(data);
} catch (err) {
console.error(err);
}
whenever I run this I am getting following Error:
Error: "toString()" failed
at stringSlice (buffer.js:558:43)
at Buffer.toString (buffer.js:631:10)
at Object.fs.readFileSync (fs.js:601:41)
at Object.<anonymous> (C:\Users\admin\Desktop\Node Files\test.js:19:19)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Function.Module.runMain (module.js:676:10)
I can figure out the problem. It because of file size.file size is 355MB. Buffer.toString fails because of exceeding the maximum supported length in V8.(>256MB) I am quite new in nodejs. how to solve this.can anyone please help