1

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.

3
  • 1
    your firebase sdk is not installed. Usually, this happens when your script is included BEFORE the firebase.js script. Commented Jul 1, 2018 at 20:33
  • What do you mean by firebase.js script? This one which is included by import * as firebase from 'firebase/app';? Commented Jul 1, 2018 at 20:35
  • If you're using angularfire2, why don't call AngularFireModule#initializeApp instead? Commented Jul 4, 2018 at 4:38

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.