Cannot find namespace 'firebase'.
With the new angularfire I get the error
ERROR in C:\temp\aspnetu\node_modules\angularfire2\database\database.d.ts
(9,29): error TS2503: Cannot find namespace 'firebase'.
ERROR in C:\temp\aspnetu\node_modules\angularfire2\database\database.d.ts
(10,31): error TS2503: Cannot find namespace 'firebase'.
ERROR in C:\temp\aspnetu\node_modules\angularfire2\utils\firebase_object_factory.d.ts
(4,76): error TS2503: Cannot find namespace 'firebase'.
ERROR in C:\temp\aspnetu\node_modules\angularfire2\utils\firebase_list_factory.d.ts
(5,74): error TS2503: Cannot find namespace 'firebase'.
...etc
The solution is using the "files" array in the tsconfig.json file.
"files": [
"node_modules/angularfire2/firebase3.d.ts"
],
Here's an alternative to fincefid's and davideast's solutions above because
the "files" property cannot be used in conjunction with the "exclude" property 1
which might be problematic for some setups. This worked for me with an Ionic v2 project.
Instead of modifying tsconfig.json, you can reference the Firebase 3 typings file that is included in the angularfire2 node package directly in your typings.json. Run:
typings install file:node_modules/angularfire2/firebase3.d.ts --save --global- this saves the reference into
typings.json - NOTE: requires typings v.1+
- this saves the reference into
typings install- this puts the typings files in the typings/ directory.
@filoxo did not know you can install typings directly from the node_modules like that :+1:
Hi everyone, Sorry to re-open the discussion... I followed the doc and your advice but I am still facing the same error "Cannot find namespace 'firebase'" when I try to build my Angular 2 web app. I use Angular CLI. I referenced "node_modules/angularfire2/firebase3.d.ts" in the files array property of tsconfig.json as @davideast suggested... Please can somebody help me ? Thanks
Instead of using node_modules/angularfire2/firebase3.d.ts that came with angularfire2, I did typings install firebase to install the one from https://github.com/typed-typings/npm-firebase. That one worked for me and I was able to do import * as firebase from 'firebase';. I really don't know why. They should be the same.
Thanks @5amfung it works !
typings install firebase installs the types as a module that must be installed, which is correct (as far as I know) for the latest firebase JS library.
The AngularFire2 library still expects the firebase types to be global (ambient) which is why in the docs it suggests typings install firebase --ambient --save (or typings install firebase --global --save).
Since the new firebase typings are marked as modules then you cannot install them globally. I found that the best trick is to use the trick by @filoxo in https://github.com/angular/angularfire2/issues/234#issuecomment-229560239
This error is still present, none of the solution above worked for me.
@IvRRimum Try updating to the latest versions of angularfire2, firebase, angular (RC5), and angular-cli. I have been using this setup without any issues.
I find that you can add
"types": [ "jasmine", "firebase" ]
to tsconfig.json
@davideast where in the installation and setup section does it mention that?
@IvRRimum How do you check / update the versions of each of those?
As for me, I followed what was suggested by @olostan and it worked for me
I'm having the same error. Please provide complete installation steps in readme. This is very confusing. 😕 😫
@harry008 https://github.com/r-park/todo-angular2-firebase This repo works. Take this and delete stuff you don't need.
Solved my issue by following steps 👇
- Added 👉
/// <reference path="../node_modules/firebase/firebase.d.ts" />tosrc/typings.d.ts - Added
"files": [ "../node_modules/firebase/firebase.d.ts" ]to and removed"types": ["firebase"]fromsrc/tsconfig.jsonas it gives error ofCould not find definitions for file 'firebase'. You can keeptypesarray for other things.
I've spent my half day just for this 😫 😓
@davideast I hope you had enjoyed your [pre/post/mid][whatever] ☕ in that meantime 😃
@IvRRimum I figured out that while hovering to https://github.com/unseen1980/Angular2-Firebase-Auth
There is so much BS going on with this implementation, and none of the above suggestion worked for me loading alternative options...................
I'm having problems too. I followed the steps by @harry008 , but I'm still getting errors about firebase.d.ts when I try ng serve:
ERROR in [default] /Users/jim/Git-Projects/Park-Boys-Bootcamp/4-Firebase-Rooms/project/node_modules/firebase/firebase.d.ts:391:2
Duplicate identifier 'export='.
ERROR in [default] /Users/jim/Git-Projects/Park-Boys-Bootcamp/4-Firebase-Rooms/project/src/typings.d.ts:6:10
';' expected.
ERROR in [default] /Users/jim/Git-Projects/Park-Boys-Bootcamp/4-Firebase-Rooms/project/src/typings/modules/firebase/index.d.ts:498:0
Duplicate identifier 'export='.
@JimTheMan looks like you have installed typings for firebase via typings install firebase or something like that. I guess that are conflicting with the referenced typings file in tsconfig.json. Try removing the firebase from typings folder and check if its working or not.
Thanks @harry008 you can check here: https://github.com/ParkBoys/Park-Boys-Bootcamp/tree/master/4-Firebase-Rooms/project
I have removed everything from the typings.d.ts file and am still getting the errors:
