Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularFire2: Cannot find namespace "firebase"

I'm trying to build a ng2 app with angularfire. Following the quickstart, I receive the following error:

cannot find namespace 'firebase'

Seems to be something with the typings, installed all of them though. Any ideas on this issue?

like image 923
sandrooco Avatar asked Aug 24 '16 08:08

sandrooco


1 Answers

If you have a fresh angular 2.0 CLI project - this will work - i don't know your particular setup:

  1. make sure that your tsconfig.json looks like this:

"compilerOptions": {

"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["es6", "dom"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types"  /// - here - types are pointing to this @types folder inside node_modules.
]

}

  1. create a new folder inside @types called firebase.
  2. create a new file inside firebase, name it index.d.ts
  3. place the content form here inside index.d.ts
  4. here are the official angularfire2 setup docs. The Troubleshooting section is not accurate - for an angular cli project. Make sure not to place any declarations or stuff inside tsconfig.json or typings.json as indicated there (as of now 28 sept 2016).

It looks like the recommended way to add typing's to an Angular 2.0 CLI project - is to add them inside node_modules/@types folder.. As you can see the jasmine typing's folder looks similar - and was automatically added there by the CLI scaffolding.

like image 194
AIon Avatar answered Sep 22 '22 10:09

AIon