Fixed Javascript Heap Out Of Memory Error.
Error:
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory (Reactjs, Webpack, javascript Heap Out of memory )
Sol-1:
Run below command in case of "npm start" failed
E:\Project\ui> node --max-old-space-size=8192 node_modules/webpack-dev-server/bin/webpack-dev-server.js
Run below command in case of "npm run build" failed
E:\Project\ui> node --max-old-space-size=8192 node_modules/webpack/bin/webpack.js
Sol-2:
Do this if npm start failed. Open node_modules\.bin\webpack-dev-server.cmd and replace node "%~dp0\..\webpack-dev-server\bin\webpack-dev-server.js" %* with below line
node --max-old-space-size=2048 node_modules/webpack-dev-server/bin/webpack-dev-server.js
Do this if npm start failed.Open node_modules\.bin\webpack.cmd and replace node "%~dp0\..\webpack-dev-server\bin\webpack.js" %* with below line
node --max-old-space-size=2048 node_modules/webpack/bin/webpack.js
Sol-3:
Run below commands
npm i increase-memory-limit
increase-memory-limit
npm i cross-env
Add below line in package.json under script object
"fix-memory-limit": "cross-env LIMIT=2048 increase-memory-limit"
Add below line in package.json under devDependencies object
"increase-memory-limit": "^1.0.3","cross-env": "^5.0.5"
Finally run below command
npm run fix-memory-limit
Note- Since my project was running succesfullly with 2GB that's why i have set max space 2048 like this "--max-old-space-size=2048". You can increase as per your requirement.
Note- Try any one among above 3 Solutions. But Sol-3 is the best way to increase the heap size.
No comments:
Post a Comment