6 thoughts on “Angular with SSR firebase bug

  1. Thanks for reporting the issue! We didn’t consider SSR use case when adding the condition. We will fix it in the next release.

    Can you please downgrade firebase to <= 5.10.0 as a workaround?

  2. Thank you very much.
    After uninstalling the latest, and then installing the canary version, That error went away.
    however, it was replaced by a new one:
    Please note it builds fine, but when SSR app, this happens.

    var major = parseInt(firebase_app__WEBPACK_IMPORTED_MODULE_6__[“SDK_VERSION”].split(‘.’)[0]);

    TypeError: Cannot read property ‘split’ of undefined

  3. Found a temporary solution in case others are interested too.
    Besides Firebase, you should also install an older version of Angular Fire.
    uninstall current installation:
    npm uninstall @angular/fire firebase --save

    then install older version, I did below:
    npm install @angular/fire@5.0.0 firebase@5.9.0 --save

    Everything worked after this.

  4. Okay. The problem is that webpack read the file pointed by module field in package.json when targeting Node. The module field in firebase/app is the esm build which only has a default export, so you are seeing the ‘SDK_VERSION’ not found error.

    The workaround is to force webpack to read the file pointed by the main field which is the cjs build. You can add a the following configuration to webpack.server.config.js:

    module.exports = {
     resolve: {
        alias: {
          ['firebase/app']: path.resolve(__dirname, 'node_modules/firebase/app/dist/index.cjs.js')

    The discrepancies between the esm build and cjs build is currently a limitation in firebase packaging and type definition. I will take it to the team and see how we can fix it. It is probably a breaking change, so we also need to think about the timing.

    A workaround can also be applied at @angular/fire, so you guys don’t need to do anything. I think it’s probably the best (temporary) solution at this time. Once I have some progress with @angular/fire solution, I will link it here.

  5. Even after upgrading to 6.0.2 , still self of undefined error comes up on Angular SSR build. Build succeeds but error comes when you try to run the local server post build