Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpack out of memory

When I'm working with a webpack-dev server, the problem sometimes occurs

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

more here

Config webpack.config.js

"webpack": "^4.5.0",
"webpack-cli": "^2.0.14",
"webpack-dev-server": "^3.1.3",

NodeJS version:

node -v
v9.3.0

OS version:

macOS High Sierra 10.13.6

Has anyone encountered a similar problem?

like image 877
Pavel Avatar asked Jul 26 '18 10:07

Pavel


3 Answers

node --max-old-space-size=8192 node_modules/webpack-dev-server/bin/webpack-dev-server.js

Run above command instead of running npm start

like image 86
Amazing Apps Avatar answered Nov 13 '22 14:11

Amazing Apps


Increase your node process's memory limit. Start node with command-line flag --max-old-space-size=2048 (to 2GB, default is 512 MB I think), or set it via environment variable NODE_OPTS https://nodejs.org/api/cli.html

like image 8
laggingreflex Avatar answered Nov 13 '22 13:11

laggingreflex


You might get away with the following. The issue is caused by a memory leak in postcss-loader. The one liner below has worked for some.

rm -rf [package-lock.json] node_modules && npm cache clean -f && npm i

For more information: https://github.com/webpack/webpack/issues/6929

like image 4
Odyssee Avatar answered Nov 13 '22 13:11

Odyssee