angularfire icon indicating copy to clipboard operation
angularfire copied to clipboard

ERROR in [default] Cannot find type definition file for 'firebase'.

Open k1ng440 opened this issue 10 years ago • 56 comments

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                                                                                                                                                                                                                                              

k1ng440 avatar Sep 17 '16 20:09 k1ng440

I have the same problem...

nydal91 avatar Sep 17 '16 20:09 nydal91

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" ] } }

nydal91 avatar Sep 18 '16 00:09 nydal91

you added "firebase" to types, right?

it didnt work for me

k1ng440 avatar Sep 18 '16 01:09 k1ng440

I don't understand the question. but I just restart the guide to I get it to work. toke some time.

nydal91 avatar Sep 18 '16 11:09 nydal91

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

mukesh51 avatar Sep 18 '16 16:09 mukesh51

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

manekinekko avatar Sep 18 '16 22:09 manekinekko

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

jeffbcross avatar Sep 19 '16 17:09 jeffbcross

i have firebase on node_modules/firebase and angularfire2/node_modules/firebase

k1ng440 avatar Sep 19 '16 17:09 k1ng440

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

jeffbcross avatar Sep 19 '16 17:09 jeffbcross

removed and it didn't solve the issue

k1ng440 avatar Sep 19 '16 17:09 k1ng440

@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" />

jeffbcross avatar Sep 19 '16 18:09 jeffbcross

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

k1ng440 avatar Sep 20 '16 15:09 k1ng440

Try adding it into "files" list in the tsconfig.json

mukesh51 avatar Sep 20 '16 16:09 mukesh51

@k1ng440 is that the right relative path, or does it need some ../ on the front?

alexeagle avatar Sep 20 '16 17:09 alexeagle

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

dmastag avatar Sep 20 '16 18:09 dmastag

i have both in app.modules.ts and it doesn't work :(

k1ng440 avatar Sep 20 '16 18:09 k1ng440

@k1ng440 Try changing the angularfire2.d.ts file directly like I mentioned

dmastag avatar Sep 20 '16 18:09 dmastag

Hi, Yes i have used ../ but still doesn't help me

/// <reference path="../../node_modules/firebase/firebase.d.ts" />

k1ng440 avatar Sep 21 '16 12:09 k1ng440

@jeffbcross Hopefully, this should remove the need to add firebase entry in types arrays in 'src/tsconfig.json' ?

mukesh51 avatar Sep 21 '16 21:09 mukesh51

@mukesh51 yep!

jeffbcross avatar Sep 21 '16 21:09 jeffbcross