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


当前回答

更换线路

"start": "ng serve -o——port 4300——configuration= zh " with

"start": "node——max_old_space_size=5096 node_modules/@angular/cli/bin/ng serve -o——port 4300——configuration= zh "

注意:

端口—4300不是常量,这取决于您选择的端口。 ——max_old_space_size=5096 too not constant;任意值1024、2048、4096等

其他回答

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

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

在我的例子中,它是一个递归,导致React用完所有内存。

这发生在我重构代码时,我没有注意到这一点。

const SumComponent = () => {
  return (
    <>
      <SumComponent />
    </>
  )
}

在其他Node.js应用程序中,这可能是这样的:

const someFunction = () => {
  ...
  someFunction();
  ...
}
node --max_old_space_size=4096 node_modules/@angular/cli/bin/ng build --baseHref=/baseUrl/ --prod=true

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

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

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