Reputation: 5619
Hi I try to compile my react-js application with webpack and this command:
"node_modules/.bin/cross-env NODE_ENV=production webpack -p --config webpack.config.js"
so it trys to minify the node modules stuff.
I got this error:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
is there a way to allocate more memory? I have 32GB that should not be the problem
thanks
Upvotes: 2
Views: 6099
Reputation: 5422
There is v8
heap limit set for your system, which you can discover with v8.getHeapStatistics in your node
repl.
Most likely you are surpassing the heap_limit_size
and one way to increase allowed memory for a process is to append additional V8 flag: --max_old_space_size
to your node when invoking it so it passes the flag down to V8 and increases the memory allocation pool size. The value should be in megabytes.
Can go something like this:
node_modules/.bin/cross-env NODE_ENV=production node --max_old_space_size=8096 node_modules/.bin/webpack -p --config webpack.config.js
You can experiment in your local dev environment with higher memory values, but always double check the possible affect of the value to your production environment, for which you can just configure separate memory values in separate npm
scripts.
Upvotes: 4