“ERROR TypeError: Object(…) is not a function” using AngularFirestore and firebase

谁说我不能喝 提交于 2019-11-26 18:56:53

I had same problem but i solved it. You can follow my work. This is a example for ionic.

Install rxjs

npm i rxjs@^6.0 rxjs-compat

import rxjs-compact to file

import { AngularFireDatabase, AngularFireList } from 'angularfire2/database';
import { Observable } from 'rxjs-compat';
import { map } from 'rxjs-compat/operators';

https://stackoverflow.com/a/50447449/6567753

AngularFire maintainer here, we've had a number of breaking changes as we march towards 5.0 GA. In order to support Angular 6, recent releases of AngularFire require rxjs 6. While yes downgrading or pinning to an old version would work for quick and dirty fix, I wouldn't suggest that as it will leave you out of improvements to the libraries in the future.

I'd recommend upgrading rxj6 to version 6 and including rxjs-compat if you have dependencies that haven't yet upgraded:

npm i rxjs@^6.0 rxjs-compat

Keep an eye on the angularfire changelog for important information on any breaking changes; once we hit GA we will abide by semver.

And for reference here's the RXJS 5 => 6 migration guide.

npm install rxjs@6 rxjs-compat@6

This solved the issue

I have the same error when installing "angularfire2": 5.0.0-rc.9.

The error is gone when I rollback to 5.0.0-rc.6.

npm install angularfire2@5.0.0-rc.6
npm install firebase@4.12.1

Remove ^ this one in front of the version. So like this.

{
    ...

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

This was my solution:

npm uninstall angularfire2
npm install angularfire2@5.0.0-rc.4
npm uninstall firebase
npm install firebase@4.8.0

I got the same error. As soon as i updated rxjs with sudo npm update rxjs. And then updated rxjs-compat with sudo npm i rxjs@latest rxjs-compat. After fixing the vulnerabilities and then running ng build then ng serve. This fixed my error. (on macOS)

I first uninstalled firebase and angularfire2 with:

  • npm uninstall firebase
  • npm uninstall angularfire2

And then reinstalled again with:

  • npm install firebase@4.12.1
  • npm install angularfire2@5.0.0-rc.6

Using ^ in the versions actually installed angularfire2@5.0.0-rc.9 so I just removed that part.

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