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


当前回答

如果这对某人有用的话。确保我们的Sass中没有递归。或者在最近添加的代码中使用不存在的递归。在某些情况下,超过Max堆就是一个标志。

其他回答

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

我没有使用ng build,而是在终端中执行以下命令来修复这个问题。

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

那就发球吧。

这就是我的终端机

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\ProjectPath\Project1> node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build --prod

只需执行以下命令:

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

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

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

对我来说,问题是有一个额外的node_modules文件夹,我重命名为node_modules_old,并运行npm install来生成一个新的node_modules。在某种程度上,构建仍然会选择node_modules_old文件夹,所以我将node_modules_old从目录中移出以解决这个问题。