Reputation: 200
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",
}
Upvotes: 0
Views: 2369
Reputation: 122
Try this script
"scripts": {
"build:dev": "NODE_OPTIONS=--max_old_space_size=6000 REACT_APP_ENV=development npm run build",
}
Upvotes: 1
Reputation: 163
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
Upvotes: 1