问题
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?
回答1:
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
回答2:
node --max-old-space-size=8192 node_modules/webpack-dev-server/bin/webpack-dev-server.js
Run above command instead of running npm start
回答3:
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
来源:https://stackoverflow.com/questions/51536623/webpack-out-of-memory