angularfire: ERROR in [default] Cannot find type definition file for 'firebase'.
Hello, I have tried every possible solution to fix this issue but none helps remove this error message.
tsconfig.json
{
"compilerOptions": {
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"skipLibCheck": true,
"lib": [
"es6",
"dom"
],
"types": [
"firebase",
"jasmine",
"node",
"protractor",
"selenium-webdriver"
],
"typeRoots": [
"../node_modules/@types"
],
"mapRoot": "./",
"module": "commonjs",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es5",
"exclude": [
"node_modules",
"dist"
]
}
}
packages.json
"angularfire2": "^2.0.0-beta.5-preview",
"firebase": "^3.4.0",
tsc -v
Version 2.0.0
angular-cli: 1.0.0-beta.11-webpack.8
node: 6.5.0
os: win32 x64
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 3
- Comments: 54 (12 by maintainers)
Commits related to this issue
- fix(imports): add firebase imports to all places that reference firebase namespace Fixes #525 — committed to jeffbcross/angularfire2 by jeffbcross 8 years ago
- docs(windows): Adds docs for installing using Angular CLI on Windows. Document installation for Windows with Angular CLI. This closes #569 and #525 — committed to angular/angularfire by mukesh51 8 years ago
@k1ng440 I solved it by either adding
import * as firebase from ‘firebase’;
or
/// <reference path="../firebase/firebase.d.ts"/>
on top of node_modules\angularfire2\angularfire2.d.ts
As mentioned over here -> https://github.com/angular/angularfire2/issues/486#issuecomment-247534422
For non-Windows users this should be solved by adding firebase into the types array of your tsconfig file.
@mukesh51 yep!
@alexeagle and I have tracked down the issue. None of our .d.ts files include any imports from
firebase
, which is causingnode_modules/firebase/firebase.d.ts
never to be loaded. Iffirebase.d.ts
ever gets loaded, it would addfirebase
to the ambient typings and make these errors go away. I’m going to refactor all of our modules to properly import from firebase instead of relying on ambient typings.In the meantime, you should be able to work around this problem by adding a reference to your project’s entry file pointing directly to
firebase.d.ts
/// <reference path="node_modules/firebase/firebase.d.ts" />
@giannico Thanks. I changed 4.8.0 to 4.6.0 in package.json and run “npm install” => Now it working.
@meanMonk,
I had the same issue last night, I was able to resolve it by rolling the firebase dependency back to 4.6.0. I didn’t get to look into the root cause of the differences between 4.6.0 definitions and 4.8.1 definitions, but this definitely solved it for me.
Just ran into this on windows myself. There’s 2 steps to fix it atm:
"firebase"
from thetypes
array intsconfig.json
/// <reference path="../node_modules/firebase/firebase.d.ts" />
to yoursrc/typings.d.ts
. Verify this file exists though, if it doesn’t you probably need to addfirebase
as a dependency.i tried to add
/// <reference path="node_modules/firebase/firebase.d.ts" />
to main.ts, typings.d.ts and app.module.ts. none of them solves this issuethanks
@NilsNaegele have you tried to delete the
node_modules
directory? or further also delete the.lock
file then runit work when i follow the Troubleshooting. https://github.com/angular/angularfire2/blob/master/docs/1-install-and-setup.md
tsconfig.json:
{ "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" ], "types": [ "firebase" ] } }
@lednhatkhanh try removing the import * as firebase from ‘firebase’; from angularfire.d.ts and then restart ng serve
In mac OS X works perfect, but in Windows 10 dont.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\angularfire2.d.ts:13:65 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\angularfire2.d.ts:15:45 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:9:39 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:10:51 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:10:91 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:11:50 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:11:118 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth.d.ts:14:55 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:6:81 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:8:48 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:13:45 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:40:10 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:42:13 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:43:13 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:44:14 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:45:15 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:48:54 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\auth_backend.d.ts:48:84 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:5:13 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:6:24 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:14:72 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:16:35 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\auth\firebase_sdk_auth_backend.d.ts:17:36 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\database.d.ts:8:28 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\database.d.ts:9:30 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_factory.d.ts:3:73 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_factory.d.ts:3:103 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:6:49 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:6:79 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:8:10 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:8:40 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:9:22 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:9:52 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:11:20 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:12:52 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:13:38 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_list_observable.d.ts:14:82 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_factory.d.ts:3:75 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:7:101 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:9:21 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:10:27 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\database\firebase_object_observable.d.ts:11:14 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:9:22 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:10:25 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:11:25 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\node_modules\angularfire2\interfaces.d.ts:12:34 Cannot find namespace ‘firebase’.
ERROR in [default] C:\proyectos\testFirebase\src\typings.d.ts:6:12 Subsequent variable declarations must have the same type. Variable ‘require’ must be of type ‘NodeRequire’, but here has type ‘any’.
ERROR in [default] C:\proyectos\testFirebase\src\typings.d.ts:7:12 Subsequent variable declarations must have the same type. Variable ‘module’ must be of type ‘NodeModule’, but here has type ‘any’. Child html-webpack-plugin for “index.html”: Asset Size Chunks Chunk Names index.html 2.81 kB 0 webpack: bundle is now VALID.
Try adding it into “files” list in the tsconfig.json