当我使用Ionic serve命令运行Ionic 3项目时,我会得到这个错误:
当前回答
在项目文件夹中运行此命令。使用服务而不是构建
node --max_old_space_size=8000 node_modules/@angular/cli/bin/ng serve --prod --port=4202
其他回答
当我运行angular 'ng serve'时,我也有类似的问题:
"致命错误:无效的标记-压缩接近堆限制分配失败- JavaScript堆内存不足"
在我的例子中,我发现我的Angular应用程序使用了惰性加载。一个模块已经导入到自己的路由模块,但有人做了一个导入它到应用程序模块,这导致递归(?)加载。
这会导致内存不足。
更换线路
"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等
检查文件夹名称。如果文件夹名中有空格,就会产生这类问题。不带空格的重命名。
我在Angular上也遇到了同样的问题。然后我写了
"serve": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng serve"
要打包的脚本。Json脚本,为我解决了这个问题。
并运行project this命令:
npm run serve
对我来说,这是一个Firebase包的问题。
在你的包中只添加"@firebase/database": "0.2.1"。json文件。重新安装node_modules,它就可以工作了。