【问题标题】:Angular-cli AOT build fails with "FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"Angular-cli AOT 构建失败并显示“致命错误:CALL_AND_RETRY_LAST 分配失败 - JavaScript 堆内存不足”
【发布时间】:2018-08-20 04:08:37
【问题描述】:

我正在尝试使用 AOT 构建我的 angular-cli 项目

ng build --aot

但它失败并出现错误

“致命错误:CALL_AND_RETRY_LAST 分配失败 - JavaScript 堆内存不足”

如果我使用 --prod 标志构建,也会发生同样的事情。

有什么想法吗?

【问题讨论】:

  • 节点版本:v9.4.0,npm 版本:= 5.6.0
  • 通常的原因是:构建机器内存不足,或者存在循环模块依赖。

标签: node.js angular angular-cli


【解决方案1】:

github上已经有issue:https://github.com/angular/angular-cli/issues/5618

同时,作为一种解决方法,您可以尝试指定 max_old_space_size 设置(以 MB 为单位)

node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --prod

【讨论】:

  • 我必须在哪里设置这个..?
  • 在您的控制台中,而不是输入 ng build --prod
  • 它在代码中给我一个错误,例如“类型 '{ [key: string]: any; }' 上不存在属性'模式'。”
  • 如果我正常运行 ng serve 它不会给我错误但在此它给我错误
  • 可能是因为现在你没有内存问题了,它在构建过程中进一步失败
【解决方案2】:

npm 安装

node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng serve

【讨论】:

    猜你喜欢
    • 2016-12-19
    • 1970-01-01
    • 2018-11-10
    • 2018-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-05
    • 2019-12-17
    相关资源
    最近更新 更多