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
Hi, is this fixed in the npm package?
@csotomon yes
dont add to tsconfig.json and you should be fine
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.
@csotomon Even though errors are thrown on Windows 10, the connectivity with Firebase should work as expected. I did raise an issue sometime back to highlight this behaviour #569
@davideast FYI.
@mukesh51 is true, the connectivity works. Thank U.
to solve this issue just copy firebase folder from /node_module to /node_module/@types it will remove all those errors...i have tried it and it worked for me finally
Just ran into this on windows myself. There's 2 steps to fix it atm:
- remove
"firebase"from thetypesarray intsconfig.json - add
/// <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 addfirebaseas a dependency.
Tried adding
import * as firebase from 'firebase';
and got this these errors instead:
ERROR in [default] C:\Users\lednh\Documents\ng2\ng2-simple-todos\node_modules\@types\firebase\index.d.ts:326:1
Duplicate identifier 'export='.
ERROR in [default] C:\Users\lednh\Documents\ng2\ng2-simple-todos\node_modules\firebase\firebase.d.ts:405:2
Duplicate identifier 'export='.
@lednhatkhanh try removing the import * as firebase from 'firebase'; from angularfire.d.ts and then restart ng serve
@mukesh51 Removing all the "import * as firebase from 'firebase';" added to commit/c3a954c worked for me.
I think a better idea is to delete firebase from @types folder.
In my case, just removing firebase from types array in tsconfig.json did not fix this issue, but also I had to remove import 'firebase' from vendor.ts file.
Which reminds me an issue I've previously reported #521
npm install --save angularfire2 firebase
In tsconfig.json add:
"files": [
"../node_modules/firebase/firebase.d.ts"
]
In anglar-cli.json file add:
"scripts": [
"../node_modules/firebase/firebase.js",
]
And in typings.d.ts file add:
declare var System: any;
declare var require: any;
declare var module: any;
Close the server and re-run ng serve
There is no need to install @types/firebase and add firebase to types array
Upgrade from Angular 2.RC4 to final with Angular-CLI
I tried some of the workarounds listed in the answers but I am not able to solve the problem. I still get
"ERROR in [default]
Cannot find type definition file for 'firebase"
while compiling with Webpack (even if the app starts and works fine).
I am working with:
- Angular 2.0.1
- firebase not installed to avoid compilation errors (see https://github.com/angular/angularfire2/issues/658)
- "angular2-firebase": "^0.7.3",
- "angularfire2": "^2.0.0-beta.4"
- angular-cli: 1.0.0-beta.16
- node: 7.2.0
- os: darwin x64
package.json is { "name": "final-project", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "start": "ng serve", "lint": "tslint "src/**/*.ts"", "test": "ng test", "pree2e": "webdriver-manager update", "e2e": "protractor", "populate-db": "./node_modules/.bin/ts-node ./populate-db.ts", "batch-server": "./node_modules/.bin/ts-node ./batch-server.ts" }, "private": true, "dependencies": { "@angular/common": "2.0.1", "@angular/compiler": "2.0.1", "@angular/core": "2.0.1", "@angular/forms": "2.0.1", "@angular/http": "2.0.1", "@angular/platform-browser": "2.0.1", "@angular/platform-browser-dynamic": "2.0.1", "@angular/router": "3.0.0", "@types/lodash": "^4.14.36", "@types/request": "0.0.30", "angular2-firebase": "^0.7.3", "angularfire2": "^2.0.0-beta.4", "core-js": "^2.4.0", "firebase-queue": "^1.5.0", "lodash": "^4.15.0", "rxjs": "5.0.0-beta.12", "ts-helpers": "^1.1.1", "zone.js": "^0.6.21" }, "devDependencies": { "@types/jasmine": "^2.2.30", "angular-cli": "1.0.0-beta.16", "codelyzer": "~0.0.26", "jasmine-core": "2.4.1", "jasmine-spec-reporter": "2.5.0", "karma": "0.13.22", "karma-chrome-launcher": "0.2.3", "karma-jasmine": "0.3.8", "karma-remap-istanbul": "^0.2.1", "protractor": "4.0.3", "ts-node": "^1.2.1", "tslint": "3.13.0", "typescript": "^2.0.2" } }
tsconfig.json is
{
"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": [
"node",
"firebase"
]
}
}
typings.d.ts is
// Typings reference file, see links for more information
// https://github.com/typings/typings
// https://www.typescriptlang.org/docs/handbook/writing-declaration-files.html
declare var System: any;
@EnricoPicci the fix should be in beta.6. Are you sure that is being used?
I removed 'firebase' from the "types" of typings.d.ts and the error disappeared. This was already suggested as a solution in this thread but, for reasons which are not clear to me, it did not work before in my case. Thanks for the support
Had the same error after upgrading nodejs on Windows 10 to v.8.9.3. Using Angulafire v.5.0.0-rc.4
Fixed it by removing
import * as firebase from 'firebase/app';
from
node_modules\angularfire2\firebase.app.module.d.ts
@timeens ,
I am stiill facing some issue after removing
import * as firebase from 'firebase/app'; from file you have suggested..
Here is error:
ERROR in node_modules/angularfire2/firebase.app.module.d.ts(4,45): error TS2503: Cannot find namespace 'fir
node_modules/angularfire2/firebase.app.module.d.ts(7,17): error TS2503: Cannot find namespace 'firebase'.
node_modules/angularfire2/firebase.app.module.d.ts(8,21): error TS2503: Cannot find namespace 'firebase'.
node_modules/angularfire2/firebase.app.module.d.ts(9,22): error TS2503: Cannot find namespace 'firebase'.
node_modules/angularfire2/firebase.app.module.d.ts(10,20): error TS2503: Cannot find namespace 'firebase'.
node_modules/angularfire2/firebase.app.module.d.ts(12,22): error TS2503: Cannot find namespace 'firebase'.
Node Version: v8.4.0 Angular cli : Angular CLI: 1.6.1 Node: 8.4.0 OS: win32 x64 Angular: 5.1.1
Here is the dependencies
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"angularfire2": "^5.0.0-rc.5-next",
"bootstrap": "^4.0.0-beta.2",
"core-js": "^2.4.1",
"firebase": "^4.8.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"rxjs": "^5.5.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.6.1",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/firebase": "^2.4.32",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
Can you guys' please help me out with this. I have tried all possible solution suggested in all the issue on github and also updated the angular cli and created new project as well still facing same issue.
Thank you in adavance.
@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.
Thank you very much @meanMonk , you saved my time, faced the same issue after upgrading ionic2 project. resolved by rolling the firebase dependency back to 4.6.0