[Solved] Vue Compile Error: JavaScript heap out of memory

Vue element UI project

The default size limit of V8 engine for memory use is 1.4g. You can set the limit through the node.js command to solve this problem. Modify the contents in the package.json file as follows.

"serve": "npx --max_old_space_size=4096 vue-cli-service serve",
"build": "npx --max_old_space_size=4096 vue-cli-service build --modern"

General Vue items

Vue didn’t put  package.json   inside  scripts  The node command of the script command of the field is hidden. We directly write the option parameters provided in V8 above to scripts  Field  node  After the command, it’s OK. An example is as follows

"build": "node --max_old_space_size=4096 build/build.js"

Read More: