Maciej Treder
Maciej Treder

Reputation: 12350

(Angular Universal) - firebase.initializeApp is not a function

I have problem with running server-side rendering together with angularfire2.

The nodeJS yields: TypeError: firebase.initializeApp is not a function

While browser build work as expected. Is there any trick which should be done to get a server-side rendering with angularfire2? So far I am initializing app:

import * as firebase from 'firebase/app';
firebase.initializeApp(firebaseConfig);

In the app.module.ts which is imported by server and browser modules.

Upvotes: 1

Views: 607

Answers (1)

Justin Noel
Justin Noel

Reputation: 6215

Did you ever get a working solution for this? I'm running into the same problem in a non-angular typescript project.

import * as firebase from 'firebase/app';
import 'firebase/auth';
import 'firebase/database';

And then:

firebase.initializeApp(firebaseConfig);

Results in :

app.core.js:2316 TypeError: undefined is not a function

That's in the browser after the build process.

The compiled app.js looks like:

    undefined(firebaseConfig);

UPDATE : I just noticed this in my build process:

[ WARN  ]  Bundling Warning
           'initializeApp' is not exported by 'node_modules/firebase/app/dist/index.esm.js'

UPDATE 2 : I modified my import and all is working well!

import firebase from 'firebase/app';

Based on : https://github.com/firebase/firebaseui-web/issues/392#issuecomment-389197920

Upvotes: 2

Related Questions