当我使用Ionic serve命令运行Ionic 3项目时,我会得到这个错误:
当前回答
添加参数——build-optimizer解决了我的问题:
Node——max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build——prod——构建优化器
我不知道为什么添加only——build-optimizer可以解决这个问题,但根据Angular文档,它应该在启用AOT编译的情况下使用,所以更新后的命令应该如下所示:
--build-optimizer=true --aot=true
Angular构建文档
其他回答
我删除了现有的Node.js模块,并运行以下命令来解决我的问题:
npm install -all
npm audit fix
试试这个解决方案,在论坛上的一个旧消息中指出:3.7.0:iOS build with——prod无法工作
打开node_modules / @ionic / app-scripts / bin / ionic-app-scripts.js
将第一行改为:
#!/usr/bin/env node
to
#!/usr/bin/env node --max-old-space-size=4096
尝试1024和2048的值,但对于一个相对较大的应用程序,你可能需要4096。
我在Angular上也遇到了同样的问题。然后我写了
"serve": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve"
要打包的脚本。Json脚本,为我解决了这个问题。
并运行project this命令:
npm run serve
更换线路
"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.js 12更新到Node.js 14为我解决了这个问题。
现在更新Node.js 16可用,我建议更新到Node.js的最新可用版本。