角度生产生成FatalProcessOutOfMemory错误

时间:2018-11-14 06:24:52

标签: angular

当我在angular应用程序中运行生产版本时,出现FatalProcessOutOfMemory错误。

enter image description here

  • 角度6.0.8
  • 类型脚本:2.7.2

3 个答案:

答案 0 :(得分:2)

对于生产版本,请运行以下命令:

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

答案 1 :(得分:1)

要生成产品,请运行以下命令:

  

node --max_old_space_size = 4096 node_modules / @ angular / cli / bin / ng构建   -目标生产

有关更多优化标志的信息,请在命令下方:

它具有内置的缓存清除功能和其他功能:

  

node --max_old_space_size = 4096 node_modules / @ angular / cli / bin / ng构建   -目标生产--build-optimizer --vendor-chunk

答案 2 :(得分:1)

导航到AppData-> Roming-> npm

打开ng.cmd文件并替换为以下代码:

  @IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe" "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node "--max_old_space_size=8192" "%~dp0\node_modules\@angular\cli\bin\ng" %*
)

并保存。