当我使用Ionic serve命令运行Ionic 3项目时,我会得到这个错误:
当前回答
对于我来说,我有一个语法错误(没有显示出来),并导致了这个错误。
其他回答
试试这个解决方案,在论坛上的一个旧消息中指出: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。
从Node.js 12更新到Node.js 14为我解决了这个问题。
现在更新Node.js 16可用,我建议更新到Node.js的最新可用版本。
我没有使用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
我在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。