问题
I want to create a new Angular 6 App with AngularFire 2. Although I followed the tutorial, I get a version error.
AngularFire2 Setup Tutorial: https://github.com/angular/angularfire2/blob/master/docs/install-and-setup.md
Even though I only tried to use an Observable as seen in the tutorial I get the following error:
ERROR in node_modules/angularfire2/angularfire2.d.ts(3,10): error TS2305: Module '"/Users/tarek/Documents/Development/web_app/apphoven-web/node_modules/rxjs/Subscription"' has no exported member 'Subscription'.
node_modules/angularfire2/firestore/collection/changes.d.ts(3,10): error TS2305: Module '"/Users/tarek/Documents/Development/web_app/apphoven-web/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/angularfire2/firestore/collection/collection.d.ts(3,10): error TS2305: Module '"/Users/tarek/Documents/Development/web_app/apphoven-web/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/angularfire2/firestore/document/document.d.ts(3,10): error TS2305: Module '"/Users/tarek/Documents/Development/web_app/apphoven-web/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/angularfire2/firestore/firestore.d.ts(3,10): error TS2305: Module '"/Users/tarek/Documents/Development/web_app/apphoven-web/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/angularfire2/firestore/interfaces.d.ts(1,10): error TS2305: Module '"/Users/tarek/Documents/Development/web_app/apphoven-web/node_modules/rxjs/Subscriber"' has no exported member 'Subscriber'.
node_modules/angularfire2/firestore/observable/fromRef.d.ts(2,10): error TS2305: Module '"/Users/tarek/Documents/Development/web_app/apphoven-web/node_modules/rxjs/Observable"' has no exported member 'Observable'.
node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
node_modules/rxjs/Subscriber.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subscriber'.
node_modules/rxjs/Subscription.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Subscription'.
Am I correct that AngularFire 2 does not support Angular 6? Because it's not written anywhere. And I don't think it's a good idea to downgrade to the old Angular CLI... So, what can I do?
回答1:
now work with
npm install --save rxjs-compat
回答2:
Install the following file
npm install --save rxjs-compat
回答3:
Add following code in polyfills.ts (window as any).global = window;
回答4:
npm install --save @rxjs-compat@5.0
回答5:
You've to fix your Rxjs imports. There are some changes in the use of rxjs from v6 onwards. so, Kindly import the observable as below
import { Observable } from 'rxjs';
instaed of import { Observable } from 'rxjs/Observable';
Hope this will fix your issue. Happy coding :)
回答6:
npm i --save rxjs-compat
helps!
来源:https://stackoverflow.com/questions/50189010/angular-6-and-angularfire2-rxjs-error