Cannot find module '@firebase/app-types/private' - Firebase throws error

蓝咒 提交于 2019-11-26 16:45:54

问题


I am working on application using angular and firebase. I installed firebase with the instructions given on site and the versions as follows,

"angularfire2": "^5.0.0-rc.4",
"firebase": "^4.8.1",

but the following error comes

ERROR in node_modules/@firebase/database/dist/esm/src/api/Database.d.ts(4,33): error TS2307: Cannot find module '@firebase/app-types/private'. node_modules/@firebase/database/dist/esm/src/core/AuthTokenProvider.d.ts(17,39): error TS2307: Cannot find module '@firebase/app-types/private'.


回答1:


It's a known issue that it's a problem with the newest npm firebase package (v4.8.1).

You need to roll back your firebase version back to 4.8.0. It was an issue with type definitions and its no longer work after updating from 4.8.0 to 4.8.1.

To fix this one,

Step 1: Uninstall with the following command

npm uninstall --save firebase

Step 2: Now, open your package.json file. There, you will find:

"angularfire2": "^5.0.0-rc.4"

Step 3: Below this line, add a this line (without the Caret(^) symbol): and save

"firebase": "4.8.0"

Step 4: Now do an npm install. Your app should work

Latest Update

Hey guys! This specific issue has been resolved with the pull request #391. Ionic team will also be rolling back part of the change that surfaced this so you shouldn't see the issue any more 😄 in the next release.




回答2:


UPDATE April/2018:

package.json:

"angularfire2": "^5.0.0-rc.6",
"firebase": "^4.12.1",

npm install




回答3:


Solution:

1. Inside package.json, remove ^ from "firebase": "^4.8.1"

1.1 Downgrade Firebase from 4.8.1 to 4.8.0 by changing 4.8.1 to 4.8.0

1.2 End result should look like this: "firebase": "4.8.0"

2. Run npm update in the Project Root. NPM will downgrade Firebase for ya

3. Run ng serve --open to check for compilation errors. There shouldn't be any.

4. Enjoy!

Reason:

Firebase had introduced some breaking changes that AngularFire2 had not coped up with yet. Until the AngularFire2 team work it out, this will be the solution.




回答4:


firebase version 4.8.2 works for me:

"angularfire2": "^5.0.0-rc.4",
"firebase": "4.8.2",


来源:https://stackoverflow.com/questions/47949311/cannot-find-module-firebase-app-types-private-firebase-throws-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!