I’m receiving the error below when trying to build and deploy our react application.
FATAL ERROR: Reached heap limit Allocation failed – JavaScript heap out of memory
Whereas I think that this is purely a JavaScript issue, I’m not sure whether I can rule out anything related to our cloud setup: A bit bucket pipeline which pushes the bundle to an S3 bucket (AWS) and is exposed via a Cloudfront distribution (AWS).
I’ve searched for a solution, and saw that this could be solved by increasing the max_old_space_size. I changed the react scripts as follows (added –max_old_space_size=6000), but this did not do the trick.
"scripts": {
...
"build:dev": "REACT_APP_ENV=development npm run build --max_old_space_size=6000",
}
Any help would be incredibly helpful.
2
Answers
In my case the problem was caused by enabling source maps for sentry so I can get more readable stack traces…
Everything’s fine after I disabled it.
EDIT: I actually removed everything sentry-related from my vite.config.js
Try this script