当我使用Ionic serve命令运行Ionic 3项目时,我会得到这个错误:


当前回答

当我在Visual Studio代码中执行ng build命令时,我得到了相同的错误。但是,当我按照以下顺序在Windows命令行上执行相同的操作时,我可以成功地构建。

步骤1。

set NODE_OPTIONS=--max_old_space_size=4096

步骤2。

ng build

其他回答

在项目文件夹中运行此命令。使用服务而不是构建

node --max_old_space_size=8000 node_modules/@angular/cli/bin/ng serve  --prod --port=4202

对于我来说,我得到了这个错误,因为我失去了对我的angular中dist文件夹设置的输出路径的访问。json文件。在我用更新的凭证重新连接到远程路径后,错误消失了。

在我的案例中,我通过安装Node.js 12.10.0版本解决了这个问题。

只需执行以下命令:

export NODE_OPTIONS="--max-old-space-size=8192"

执行如下命令:

export NODE_OPTIONS="--max-old-space-size=2048"

检查你已经有多少钱了:

> node
> v8.getHeapStatistics()
{
  total_heap_size: 6049792,
  total_heap_size_executable: 524288,
  total_physical_size: 5477720,
  total_available_size: 1094444024,
  used_heap_size: 4141728,
  heap_size_limit: 1098907648,
  malloced_memory: 8192,
  peak_malloced_memory: 582752,
  does_zap_garbage: 0,
  number_of_native_contexts: 2,
  number_of_detached_contexts: 0
}

然后heap_size_limit: 1098907648