vue-element-ui 项目
V8引擎对内存的使用的默认大小限制是1.4G,可以通过node.js命令设置限制来解决这个问题。修改package.json文件中内容,具体如下。
"serve": "npx --max_old_space_size=4096 vue-cli-service serve",
"build": "npx --max_old_space_size=4096 vue-cli-service build --modern"
一般vue项目
vue没有把 package.json
里面 scripts
字段的脚本命令的node命令隐藏起来,我们直接把上面v8提供的选项参数直接写入scripts
字段的 node
命令后就好了,示例如下
"build": "node --max_old_space_size=4096 build/build.js"
参考文档:
vue编译报错JavaScript heap out of memory,node内存溢出,Exit status 134