NODE.JS: FATAL ERROR- JS Allocation failed - process out of memory, while parsing large excel files

前端 未结 1 1806
故里飘歌
故里飘歌 2021-01-30 14:11

I am using nodejs to parse xlsx files with module \"jsxlsx_async\" and values will be stored in mongodb. My code:

    xlsx(file, function(err,wb){
        if (er         


        
1条回答
  •  北荒
    北荒 (楼主)
    2021-01-30 14:40

    I had a similar problem before. I need to read a huge JSON object from a txt file, but the process was killed because it ran out of memory. Regarding this problem, my solution was to split this huge file into 2 files.

    Regarding your problem, my suggestions are:

    1. Try increasing memory limit of v8 engine. https://github.com/joyent/node/wiki/FAQ Example (8192 means 8GB):

      node --max-old-space-size=8192 server.js 
      
    2. If #1 does not work, try reading xlsx file row by row with this lib: https://github.com/ffalt/xlsx-extract

    3. If #1, #2 do not work, try https://github.com/extrabacon/xlrd-parser

    0 讨论(0)
提交回复
热议问题