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
I have the same problem...
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" ] } }
you added "firebase" to types, right?
it didnt work for me
I don't understand the question. but I just restart the guide to I get it to work. toke some time.
@k1ng440 I'll recommend try the install guide again. you "ng -v" gives angular-cli: 1.0.0-beta.11-webpack.8 , where as angular-cli has got updated. so may be worth un-installing and re-installing angular-cli. Also, I've faced issues on windows system and have seen others also facing different issues on windows, but everything seems to be working fine on linux based system. Just so you know.
I could reproduce this issue. It guess this might be a regression, because it seemed to be fixed in early versions.
I don't know if it's related to angularfire2 or angular-cli
//cc @TheLarkInn @davideast any idea?
angular-cli: local (v1.0.0-beta.14, branch: master)
node: 6.4.0
os: darwin x64
@angular/core: ^2.0.0
angularfire2: ^2.0.0-beta.5
firebase: ^3.4.0
@k1ng440 I'm curious, is the firebase package installed in your root node_modules (i.e. your-app/node_modules/firebase), or is it just installed inside your-project/node_modules/angularfire2/node_modules/firebase?
i have firebase on node_modules/firebase and angularfire2/node_modules/firebase
@k1ng440 thanks. This might be an issue with AF2 still depending on 3.3.0, and TypeScript might not be resolving the types correctly since there are two instances of firebase.
As an experiment, could you delete node_modules/angularfire2/node_modules/firebase and then see if the problem is solved?
removed and it didn't solve the issue
@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" />
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
Try adding it into "files" list in the tsconfig.json
@k1ng440 is that the right relative path, or does it need some ../ on the front?
@k1ng440 I solved it by either adding
import * as firebase from 'firebase';
or
///
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.
i have both in app.modules.ts and it doesn't work :(
@k1ng440 Try changing the angularfire2.d.ts file directly like I mentioned
Hi, Yes i have used ../ but still doesn't help me
/// <reference path="../../node_modules/firebase/firebase.d.ts" />
@jeffbcross Hopefully, this should remove the need to add firebase entry in types arrays in 'src/tsconfig.json' ?
@mukesh51 yep!