Gatsby and Netlify CMS were running nicely for a while but now it fails when trying to run gatsby develop
. With a "JavaScript heap out of memory" error.
Every npm is updated and I've tried export NODE_OPTIONS=--max_old_space_size=4096
that some GitHub issue threads mention.
You hit the nail with the command to fix it:
export NODE_OPTIONS=--max_old_space_size=4096
However, adding the previous script in the terminal will fix it locally, it may work if your gatsby develop
or gatsby build
fails but not in the server.
To fix it there in the server (Netlify side), you need to reach to the nettlify-cli
. The easiest way to do it is by adding a file named netlify.toml
in the root of your project with the following content.
[build.environment]
NODE_OPTIONS = "--max_old_space_size=4096"
Basically you are setting the Node options when Netlify builds the site exactly in the same way you did it in the terminal.
The issue comes from the Node side; it seems that the extra transpiling being done is just now making Node hit its default limit without increasing it automatically.
If you need more information about the netlify.toml
file check out the File-based configuration documentation of Netlify.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With