欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2022-03-20 23:29:21
在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...

在react项目执行 npm run build 报错

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

解决办法

更改package.json文件中的build项
npm run build报错Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of

更改前

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

更改后

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

添加 --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 默认的内存限制大小就会报这个错误

本文地址:https://blog.csdn.net/The_Small_White/article/details/107456742