npm run build报错Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of

在react项目执行 npm run build 报错

Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

解决办法

更改package.json文件中的build项
在这里插入图片描述

更改前

在这里插入图片描述

更改后

在这里插入图片描述

添加 --max_old_space_size=4096即可

扩展

CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory JavaScript堆内存不足,Node 是基于V8引擎,在一般的后端开发语言中,在基本的内存使用上没有什么限制,但是在 Node 中通过 JavaScript 使用内存时只能使用部分内存(64位系统下约为1.4 GB,32位系统下约为0.7 GB),这就是我们编译项目时为什么会出现内存泄露了,因为前端项目如果非常的庞大,webpack 编译时就会占用很多的系统资源,如果超出了V8对 Node 默认的内存限制大小就会报这个错误

猜你喜欢

转载自blog.csdn.net/The_Small_White/article/details/107456742