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


当前回答

当我在Visual Studio Code中执行以下语句时,我得到了相同的错误消息。但是当我在Windows命令行中执行相同的东西时,我可以成功地构建。

npm install -g increase-memory-limit
increase-memory-limit
set NODE_OPTIONS=--max_old_space_size=4096
ng build -c deploy --build-optimizer --aot --prod --sourceMap

其他回答

更换线路

"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等

我没有使用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

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

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

当我在Visual Studio Code中执行以下语句时,我得到了相同的错误消息。但是当我在Windows命令行中执行相同的东西时,我可以成功地构建。

npm install -g increase-memory-limit
increase-memory-limit
set NODE_OPTIONS=--max_old_space_size=4096
ng build -c deploy --build-optimizer --aot --prod --sourceMap

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