JavaScript heap out of memory error.


Question.

I have an JavaScript heap out of memory error.

How to resolve?

Answer.

Sometimes, when processing a large data set, for example a large CSV file (~>100Mb), you may face nodejs memory issue, such as: "Allocation failed - JavaScript heap out of memory".

Try to extend available nodejs memory heap by executing the following command:

# For the Windows OS:
set NODE_OPTIONS=--max-old-space-size=8192

# For the MAC/LINUX OS:
export NODE_OPTIONS=--max-old-space-size=8192

This example of the command extends the maximum allowed memory size up to 8Gb.

Last updated on 29th Jan 2023