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

Most upvoted comments

@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.

@alexeagle and I have tracked down the issue. None of our .d.ts files include any imports from firebase, which is causing node_modules/firebase/firebase.d.ts never to be loaded. If firebase.d.ts ever gets loaded, it would add firebase 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" />

firebase_error
@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:

  • remove "firebase" from the types array in tsconfig.json
  • add /// <reference path="../node_modules/firebase/firebase.d.ts" /> to your src/typings.d.ts. Verify this file exists though, if it doesn’t you probably need to add firebase 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 issue

thanks

@NilsNaegele have you tried to delete the node_modules directory? or further also delete the .lock file then run

npm install
// then 
npm install --save-exact firebase
// or
yarn
// then
yarn add -E firebase

it 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.

C:\proyectos\testFirebase>ng serve ** NG Live Development Server is running on http://localhost:4200. ** 6541ms building modules 31ms sealing 0ms optimizing 0ms basic module optimization 94ms module optimization 0ms advanced module optimization 16ms basic chunk optimization 0ms chunk optimization 0ms advanced chunk optimization 0ms module and chunk tree optimization 125ms module reviving 0ms module order optimization 0ms module id optimization 0ms chunk reviving 0ms chunk order optimization 15ms chunk id optimization 63ms hashing 0ms module assets processing 140ms chunk assets processing 0ms additional chunk assets processing 0ms recording 0ms additional asset processing 1860ms chunk asset optimization 1375ms asset optimization 47ms emitting Hash: 2e01e12af9286806d79f Version: webpack 2.1.0-beta.22 Time: 10322ms Asset Size Chunks Chunk Names main.bundle.js 3.27 MB 0, 2 [emitted] main styles.bundle.js 10.2 kB 1, 2 [emitted] styles inline.js 5.53 kB 2 [emitted] inline main.map 3.4 MB 0, 2 [emitted] main styles.map 14 kB 1, 2 [emitted] styles inline.map 5.59 kB 2 [emitted] inline index.html 479 bytes [emitted] assets/.npmignore 0 bytes [emitted]

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