JavaScript heap out of memory error.


Question

I'm encountering a "JavaScript heap out of memory" error. How can I resolve this?


Answer

This error often occurs when processing large datasets, such as a CSV file larger than 100MB. To resolve this, you can increase the available memory for Node.js by adjusting the heap size. Here's how to set the maximum allowed memory size to 8GB:

For Windows OS:

set NODE_OPTIONS=--max-old-space-size=8192

For Mac/Linux OS:

export NODE_OPTIONS=--max-old-space-size=8192
Last updated on 20th Apr 2024