700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 执行 npm 命令时报错:Allocation failed - JavaScript heap out of memory

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

时间:2021-09-01 05:26:55

相关推荐

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

执行 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 参数

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。