I\'m trying to deploy a reactjs application to heroku. While compiling assets, the build fails and produces this error:
-----> Ruby app detected
----->
I had a similar heap allocation error while deploying to Heroku. The app would still build correctly but would not load in the browser. Heroku logs would show me this: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
After trying a dozen different things this seemed to work in package.json:
"start": "react-scripts --max_old_space_size=4096 start",
"build": "react-scripts --max_old_space_size=4096 build",
In my case this error was caused by the fact that I imported twice the same less files:
@import "~@myPackage/file1.less";
@import "~@myPackage/file1.less";
@import "~@myPackage/file2.less";
@import "~@myPackage/file2.less";
The root cause of the issue is due to large source file sizes.
If the underline problem is within your source code you can resolve it by simply increasing the Node Heap Size as below,
"start": "react-scripts --max_old_space_size=4096 start",
"build": "react-scripts --max_old_space_size=4096 build",
But if the problem lies within any dependencies introduced, we may need to increase the Node Heap allocation globally to resolve the issue.
For Windows:
set NODE_OPTIONS=--max_old_space_size=4096
For Linux:
export NODE_OPTIONS=--max_old_space_size=4096
That problem is related with large files in your project.
I'm using create-react-app, and I got that error, after doing some search, it seems one solution is this.
Put in .env file:
GENERATE_SOURCEMAP=false
I had the same error. Fixed it by using an earlier version of Node/npm. Might fix your problem.
its because more "js" files in your react Application. You can build your application after making some Changes in package.json like below of code:
"scripts": {
"start": "react-scripts --max_old_space_size=4096 start",
"build": "react-scripts --max_old_space_size=4096 build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},