[Solved] Vue-cli3 running or packaging error: JS memory overflow

Error Messages: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory
Solution:
Step 1.
Install the npm packages increase-memory-limit and cross-env
npm install increase-memory-limit cross-env -g
Step 2.
Add to package.json.
“fix-memory-limit”: “cross-env LIMIT=4096 increase-memory-limit”

"scripts": {
	"serve": "vue-cli-service serve",
	"build": "vue-cli-service build",
	"fix-memory-limit": "cross-env LIMIT=10000 increase-memory-limit"
},

Step 3:

Execute fix memory limit:

npm run fix-memory-limit

Step 4:

Error message: node — Max old space size = 4096 is not an internal or external command

Solution: on node_modules/.Modify “% _prog%” under bin to%_prog%

After the replacement, restart NPM run serve to execute successfully. If the error is still reported and the memory overflows, you can try to increase the 4096

Read More: