Ionic build with firebase fail (Javascript heap out of memory)


Hi everyone,

I am facing a weird issue. I can’t build with --prod anymore. After removing most of my code until it works again it seems that firebase is the issue.
Just calling that firebase.auth().signInWithPopup(provider) cause the memory issue. If I comment it everything works fine.

I tried to update my packages but Ionic build is not working with the lastest version of typescript and the latest version of angularfire2 has issue with firebase…

“angularfire2”: “^5.0.0-rc.5-next”,
“firebase”: “^4.11.0”,

@ionic/app-scripts”: “3.1.9”,
@types/firebase”: “^3.2.1”,
“typescript”: “~2.7.2”

Anyone has the same problem and an idea ?

Everything used to work well before


Why are you calling a firebase method directly?

Why aren’t you using AngularFireAuth:

import { AngularFireAuth } from 'angularfire2/auth';



That doesn’t change the problem. If I call auth.signInWithPopup on AngularFireAuth I still have the memory issue with ionic build --prod


maybe this helps Help with the installation please

Also, I know it not exactly because I use older version, should since npm 8?? an option for that available.

Best regards, anna-liebt


That doesn’t help me it just make the build longer before it fails


It actually help.
I need to find a way to change new firebase.auth.GoogleAuthProvider(); because that crash too.

I think the problem is because of package not matching. Does Ionic has a dependancy checker ?


I had the same issue. I’ve taken my memory to 12gb and still had the issue. The only workaround is use the following instead of --prod:

ionic cordovoa build android --minifycss --minifyjs --aot

The issue, as someone in the github thread suggests, seems to be in the --optimizejs flag used by --prod. that causes the heap out of memory issue.


On my side is was really using firebase instead of AngularFireAuth.
And auth.GoogleAuthProvider() instead of firebase.auth.GoogleAuthProvider()


That’s good to know. I had tried downgrading firebase but I will try this. Thanks.