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


当前回答

对于我来说,我有一个语法错误(没有显示出来),并导致了这个错误。

其他回答

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

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

我在CentOS服务器7上也有同样的问题,但这解决了我的问题:

node --max-old-space-size=X node_modules/@angular/cli/bin/ng build --prod

其中X =(2048或4096或8192 o..)是内存的值。

我想有很多方法可以达到这个错误!

在我这边,我的package.json中有一个循环。项目A依赖于项目B,项目B又依赖于项目A。

执行如下命令:

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

由于某些原因,之前所有的答案对我都不起作用。我做了以下来解决我的问题:

我必须首先删除node_modules文件夹 在我的电脑上重新安装Node.js 然后安装NPM