angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

Cannot read property 'FacebookAuthProvider' of undefined - 2.0.0-beta.5

Open mquentin opened this issue 10 years ago • 36 comments

Hello,

Since I have updated my angularfire2 to the 2.0.0-beta.5 version, I have got an error about the FacebookAuthProvider. I do not use this provider and it seems that the problem come form my loaded angularfire2.umd.js file.

Do you guys encounter the same issue ?

mquentin avatar Sep 28 '16 14:09 mquentin

@isaquesuzuki Change version of angular packages in package.json and run npm update

samedii avatar Dec 05 '16 15:12 samedii

Thanks @samedii. Is there any problem if npm warns me about [email protected] requiring a peer of @angular/[email protected]?

isaquesuzuki avatar Dec 05 '16 16:12 isaquesuzuki

@isaquesuzuki Try and see if it works. I think I maybe got it to work by using version 2.1.1 and not 2.2.1

samedii avatar Dec 05 '16 16:12 samedii

I have two projects, ones is working, the other one, it isn't, the one that is working is showing more files loaded when I pause the execution just before var _a = firebase.auth;, the one that it's not working it's only showing firebase.js. The one that it's working shows app.js, auth.js, database.js, storage.js and firebase.js.

The version that is working is 3.4, the one that it's not working is 3.6.3.

For me, to make v3.6.3 to work (for now, not a solution, just a workaround), was to include this lines: var firebase = require('./app'); require('./auth'); require('./database'); require('./storage'); module.exports = firebase;

in firebase.js

arielcessario avatar Dec 09 '16 10:12 arielcessario

@arielcessario this works for me too as a workaround. Any word on the official solution to this issue?

After digging a bit deeper I was able to figure out a decent solution. I just changed my system.js.config firebase definition to point to firebase-browser.js instead of firebase.js.

'firebase': {
    defaultExtension: 'js',
    main: './firebase-browser.js'
}

rchipman avatar Dec 13 '16 17:12 rchipman

I added and updated wiki pages for that for Angular2 seed.

this.addPackageBundles({
      name: 'firebase',
      path: 'node_modules/firebase/',
      packageMeta: {
        main: 'firebase-browser.js',
        defaultExtension: 'js'
      }
    });

https://github.com/mgechev/angular-seed/wiki/Integration-with-Firebase https://github.com/mgechev/angular-seed/wiki/Integration-with-AngularFire2

mcchae7 avatar Dec 16 '16 05:12 mcchae7

@xmcchae7 I updated the project.config.ts as above, but still get 'Uncaught TypeError: Cannot read property 'FacebookAuthProvider' of undefined' after a prod.build. Would you have any other ideas on this fix for this?

stuartdrennan avatar Dec 16 '16 09:12 stuartdrennan

@stuartdrennan I used Firebase only, you can see my example here -> Full Source: https://github.com/GoEngin/GoEnginO firebase.initializeApp: https://github.com/GoEngin/GoEnginO/blob/master/src/client/app/app.component.ts using firebase: https://github.com/GoEngin/GoEnginO/blob/master/src/client/app/shared/util/dataaccess.ts

mcchae7 avatar Dec 16 '16 23:12 mcchae7

@mcchae7 thanks, sorry. That doesn't help with my project for some reason though. I'm using angularfire2.

"angularfire2": "^2.0.0-beta.6"
"firebase": "^3.6.4"

Its fine in development, but only errors on prod.build version.
I've tried all the suggestions I can see here; changing project.config.ts, changing angularfire2.umd.js fixes it in development but not in production.

Any thoughts would be much appreciated? :)

stuartdrennan avatar Dec 17 '16 10:12 stuartdrennan

For a test, I cloned the latest angular2-seed and installed only angularfire2 with the same result. Fine in development, errors on production build. The https://github.com/mgechev/angular-seed/wiki/Integration-with-AngularFire2 intructions say to use [email protected] & [email protected] but [email protected] doesn't contains 'firebase-browser.js' so the build is not happy with that version.

stuartdrennan avatar Dec 18 '16 09:12 stuartdrennan

firebase = firebase.firebase; dont work when

packageMeta: {
        main: 'firebase-browser.js',
        defaultExtension: 'js'
      }

to solve this then use

packageMeta: {
        main: 'firebase.js',
        defaultExtension: 'js'
      }

and now you can use firebase = firebase.firebase; on angularfire2.umd.js file

renearias avatar Jan 20 '17 16:01 renearias

This is still an issue with 2.0.0-beta.7.1-pre I still get Uncaught TypeError: Cannot read property 'FacebookAuthProvider' of undefined even though I am not using any auth providers. I have tried every approach mentioned here with no success, also tried downgrading to firebase 3.4.0 Any ideas?

arielfaur avatar Feb 09 '17 18:02 arielfaur

Making the change in the packagemeta object fix the issue with the build process, but it seems other things get broken. In my case, I am using storage API and now the app is throwing an error related with it: firebase.storage is not a function.

Any suggestion?

thanks!!

Edit: I solved this. I adapted the imports to the new object structure, I had to disable the tslinter as well. I will keep doing some test around that, if I find something new, I will put here.

Thanks

amedinavalencia avatar Feb 15 '17 18:02 amedinavalencia

I've faced with the same issue. Resolved with changes angularfire2.udm.js file as @AnthonySoler and @evellynsc saggested. But I not sure that's best aproach, because it might be a reason of another issues in future.

metallimiach avatar Feb 28 '17 15:02 metallimiach

Has there been any update on this? I've tried adding the firebase = firebase.firebase; bit to angularfire2.umd.js file and am still getting errors.

kilka avatar Mar 19 '17 18:03 kilka

Thanks @arielcessario , I have fixed it..

digitaldynamics avatar Aug 01 '18 11:08 digitaldynamics