执行 npm 命令时报错:Allocation failed - JavaScript heap out of memory

编程知识 行业动态 更新时间:2024-06-13 00:17:48

执行 npm 命令时报错:

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

原因是 JavaScript堆内存不足,Node 是基于V8引擎,在 Node 中通过 JavaScript 使用内存时只能使用部分内存(64位系统下约为1.4 GB),如果内存不足,可以用下面方法来放宽V8默认的内存限制。

法一:添加参数 --max_old_space_size=4096

npm run start --max_old_space_size=4096

法二:修改cmd文件

在目录node_modules/.bin下打开ng.cmd和ngc.cmd文件,添加 --max_old_space_size=4096

法二:通过 increase-memory-limit 插件

安装插件:npm install -g increase-memory-limit

执行命令:npx cross-env LIMIT=4096 increase-memory-limit

通过 log 可以发现它会将所有执行 node 命令的地方加上--max-old-space-size=4096 参数

 

 

更多推荐

执行 npm 命令时报错:Allocation failed - JavaScript heap out of memory

本文发布于:2023-03-25 19:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/c373533d34cdd2316c672758cada3c4a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:时报   命令   Allocation   npm   heap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!