2

I am trying to load a very large JSON file (360 Mb) on Node + Express but the line below returns this error. How should I process it then?

var emails = require("../fake_IO/cleaned_data_lang.json");

ERROR:

Error: 'toString()' failed
at Buffer.toString (buffer.js:495:11)
at Object.fs.readFileSync (fs.js:552:33)
at Object.Module._extensions..json (module.js:585:20)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at loadEmails (C:\Users\me\Workspace\myProj\rules_handler\rules-ctrl.js:22:16)
at exports.executeRules (C:\Users\me\Workspace\myProj\rules_handler\rules-ctrl.js:12:51)

1 Answers1

0

Try to use noded fs fs.createReadStream() instead of require the file directly. I found a comment somewhere about it, give it a go. #here

Community
  • 1
  • 1
Mazarelo
  • 3
  • 2