根据错误提示,是 JS 内存溢出了,可能因为项目庞大文件过多导致的
可以使用 increase-memory-limit 提高内存限制再运行项目
安装 cross-env 和 increase-memory-limit:
pnpm add -D cross-env
pnpm add -D increase-memory-limit
package.json 中定义任务:
"scripts": {
"serve": "vue-cli-service lint --no-fix && vue-cli-service serve",
"fix-memory-limit": "cross-env LIMIT=8192 increase-memory-limit"
},
先修改内存限制再启动项目:
pnpm run fix-memory-limit
pnpm run serve
参考链接:
- https://github.com/mzohaibqc/antd-theme-webpack-plugin/issues/98
- https://itsmycode.com/fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-failed-javascript-heap-out-of-memory/
- https://stackoverflow.com/questions/56742334/how-to-use-the-node-options-environment-variable-to-set-the-max-old-space-size-g
- https://stackoverflow.com/questions/56147253/nodejs-express-how-to-set-max-old-space-size-in-package-json
- https://github.com/npm/npm/issues/12238#issuecomment-308046093
- https://github.com/endel/increase-memory-limit#running-from-npm-task
- https://blog.csdn.net/m0_37448301/article/details/113245717