angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

ReferenceError: firebase is not defined

Open asadsahi opened this issue 10 years ago • 7 comments

With a new cli based project, getting above error while trying to reference TIMESTAMP variable .

this trick hasn't helped.

I have tried importing firebase in main file: import 'firebase';

Also, tried importing firebase in angular-cli.json, get require not defined in FacebookAuthProvider.

Using Angular 2 final with latest version of angularfire2 (beta 5)

asadsahi avatar Sep 17 '16 10:09 asadsahi

@asadsahi do you have the following entry in src/tsconfig.json

"types": [ "firebase" ]

mukesh51 avatar Sep 17 '16 11:09 mukesh51

@mukesh51 Great news, duplicate identifier after adding this entry :)

image

I think firebase typings is not needed anymore.

firebase global variable isn't available for some reason, even I import it in main file, doesn't seem like a typings issue.

asadsahi avatar Sep 17 '16 12:09 asadsahi

Interesting. I just did a full install following this documentation setup on Ubuntu 14.04 and it working as expected. I have to add the firebase entry in tsconfig.json to resolve the error around firebase namespace.

I had issues on windows machine, but different. not worth mentioning here.

@davideast any thoughts ?

mukesh51 avatar Sep 17 '16 15:09 mukesh51

@asadsahi you're correct, @types/firebase is no longer needed.

Can you share the whole file where you're trying to access TIMESTAMP? (Even better if you can provide a Github repo with the full project).

jeffbcross avatar Sep 22 '16 00:09 jeffbcross

@jeffbcross I only like magic on TV, but for some reason am witnessing magic on my project too, The issue has resolved for some reason, The only change i have done is updated angular-cli from beta 14 to beta 15 and reinstall node_modules.

Not having firebase undefine error, hence closing this.

asadsahi avatar Sep 22 '16 10:09 asadsahi

this.timestamp = firebase.database['ServerValue']['TIMESTAMP'];

slvn-dev avatar Oct 19 '16 08:10 slvn-dev

try this: declare var firebase: any;

adarshashu96 avatar Mar 10 '17 06:03 adarshashu96