Angular 12 Throwing this error FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

Angular 12 Throwing this error FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

我将我的 angular 应用程序版本从 angular 8 更新到 12,在以前的版本中,当我正确地访问 ng 服务器时,我的应用程序服务器没有通过任何错误,但是在将它更新到 V12 之后它通过当我 运行 by

时我出错了
  1. 服务
  2. node --max_old_space_size=8048 ./node modules/@angular/cli/bin/ng serve

以上命令也不起作用,它显示错误

这个错误似乎与sourceMaps的生成有关。这是 Github.

上的问题

您可以尝试在 angular.json 中禁用 sourceMaps 的生成作为解决方法,直到问题得到解决:

"sourceMap": false

我有这个东西,然后我把我的脚本改成了这个:

 "start": "node --max_old_space_size=2192 ./node_modules/@angular/cli/bin/ng serve",
 "build": "node --max_old_space_size=2192 ./node_modules/@angular/cli/bin/ng build --configuration production --build-optimizer=false --output-hashing=all",

但是构建问题并没有消失,所以我将节点更新到版本 16,现在它可以工作了