While walking through Thinkster.io's AngularJS tutorial chapter 4 (Three-way data binding with a real-time server), I encountered some problems.
The tutorial advises us to:
- run
bower install angularfire --save
- add
firebase
to the list of required modules - add a constant
FIREBASE_URL
to ourapp
After implementing the posts functionality, I tried it in the browser and got the following error (in Chrome console):
Uncaught Error: [$injector:modulerr] Failed to instantiate module angNewsApp due to:
Error: [$injector:modulerr] Failed to instantiate module firebase due to:
Error: [$injector:nomod] Module 'firebase' is not available! You either misspelled the mo...<omitted>...1)
Some Googling led me to realize I need to include angularfire.js
in my index.html
, which was absent:
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
... snip ...
<script src="bower_components/angularfire/angularfire.js"></script>
<!-- endbower -->
<!-- endbuild -->
This wasn't enough either, the error in Chrome:
Uncaught ReferenceError: Firebase is not defined angularfire.js:20
Error: [$injector:unpr] Unknown provider: $firebaseProvider <- $firebase <- Post
http://errors.angularjs.org/1.2.6/$injector/unpr?p0=NaNirebaseProvider%20%3C-%20%24firebase%20%3C-%20Post
at http://127.0.0.1:9000/bower_components/angular/angular.js:78:12
at http://127.0.0.1:9000/bower_components/angular/angular.js:3538:19
at Object.getService [as get] (http://127.0.0.1:9000/bower_components/angular/angular.js:3665:39)
at http://127.0.0.1:9000/bower_components/angular/angular.js:3543:45
at getService (http://127.0.0.1:9000/bower_components/angular/angular.js:3665:39)
at Object.invoke (http://127.0.0.1:9000/bower_components/angular/angular.js:3687:13)
at http://127.0.0.1:9000/bower_components/angular/angular.js:3544:37
at getService (http://127.0.0.1:9000/bower_components/angular/angular.js:3665:39)
at invoke (http://127.0.0.1:9000/bower_components/angular/angular.js:3687:13)
at Object.instantiate (http://127.0.0.1:9000/bower_components/angular/angular.js:3708:23)
Finally, I fixed it by doing the following:
bower install firebase --save
This magically added the following to the scripts collection in my index.html
:
<script src="bower_components/firebase/firebase.js"></script>
<script src="bower_components/firebase-simple-login/firebase-simple-login.js"></script>
I removed the second script and all is working well now.
I'm not sure whether the thinkster.io instructions are incomplete, or whether installing angularfire
is supposed to implicitly bring in firebase
and isn't doing so for some reason.
Hi, I had the same issue. and I found that I ran the command in a wrong directory. You have to run it in ang-news dir which contains bower.json. In this way, firebase can be installed successfully.
Running in wrong dir
rookiebird@Nest:~/workspace/ang-news/app > bower install firebase --save
bower firebase#* cached git://github.com/firebase/firebase-bower.git#1.0.11
bower firebase#* validate 1.0.11 against git://github.com/firebase/firebase-bower.git#*
bower no-json No bower.json file to save to, use bower init to create one <------ This is the error
Running in ang-news
rookiebird@Nest:~/workspace/ang-news > bower install angularfire --save
bower angularfire#* cached git://github.com/firebase/angularFire.git#0.7.1
bower angularfire#* validate 0.7.1 against git://github.com/firebase/angularFire.git#*
bower angular#~1.2.0 cached git://github.com/angular/bower-angular.git#1.2.16
bower angular#~1.2.0 validate 1.2.16 against git://github.com/angular/bower-angular.git#~1.2.0
bower firebase#~1.0.5 cached git://github.com/firebase/firebase-bower.git#1.0.11
bower firebase#~1.0.5 validate 1.0.11 against git://github.com/firebase/firebase-bower.git#~1.0.5
bower firebase-simple-login#~1.3.0 cached git://github.com/firebase/firebase-simple-login.git#1.3.2
bower firebase-simple-login#~1.3.0 validate 1.3.2 against git://github.com/firebase/firebase-simple-login.git#~1.3.0
bower angularfire#~0.7.1 install angularfire#0.7.1
bower firebase#~1.0.5 install firebase#1.0.11
bower firebase-simple-login#~1.3.0 install firebase-simple-login#1.3.2
angularfire#0.7.1 app/bower_components/angularfire
├── angular#1.2.15
├── firebase#1.0.11
└── firebase-simple-login#1.3.2