简体   繁体   English

模块“@firebase/firestore”在 Angular 12 中没有导出成员“类型”错误

[英]Module '"@firebase/firestore"' has no exported member 'type' ERROR in Angular 12

I am working on a project on Angular 12 and I use Firestore to store my datas.我正在 Angular 12 上开展一个项目,我使用 Firestore 来存储我的数据。

In my app module, I imported the needed Modules as follows (it was automatically added when I added firebase to my project):在我的应用程序模块中,我按如下方式导入了所需的模块(当我将 firebase 添加到我的项目时自动添加):


import { initializeApp, provideFirebaseApp } from '@angular/fire/app';
import { environment } from '../environments/environment';
import { provideFirestore, getFirestore } from '@angular/fire/firestore';

...
imports: [
    ...
    provideFirebaseApp(() => initializeApp(environment.firebase)),
    provideFirestore(() => getFirestore()),
  ],
...

When I followed the tutorial and try to add a document into a collection, I need to import "AngularFirestore", I do this as follows in my component ts:当我按照教程尝试将文档添加到集合中时,我需要导入“AngularFirestore”,我在我的组件 ts 中按如下方式执行此操作:


import { AngularFirestore } from '@angular/fire/compat/firestore';

constructor(private firebase: AngularFirestore) {}

const ref = this.firebase.collection('collection-name');
ref.add(my-data);

I was expecting the app to work but it crashes once I import "AngularFirestore" and I get the following error: The error我原以为该应用程序可以正常工作,但是一旦我导入“AngularFirestore”它就会崩溃,并且出现以下错误:错误

The versions I am working with are:我正在使用的版本是:

the versions版本

Edit your app module imports as follows按如下方式编辑您的应用程序模块导入

import { initializeApp, provideFirebaseApp } from '@angular/fire/app';
import { provideFirestore, getFirestore } from '@angular/fire/firestore';
import { AngularFireModule } from '@angular/fire/compat';
import { AngularFirestoreModule } from '@angular/fire/compat/firestore'
import { environment } from '@env/enviroment';

....

imports [
AngularFirestoreModule,
AngularFireModule.initializeApp(environment.firebase),
provideFirebaseApp(() => initializeApp(environment.firebase)),
provideFirestore(() => getFirestore()),
]

Hopefully that helps希望这有帮助

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Angular fire firestore 没有导出成员 'FirestoreSettingsToken' - Angular fire firestore has no exported member 'FirestoreSettingsToken' 如何修复:“@angular/fire”没有导出成员“AngularFireModule”.ts(2305) ionic, firebase, angular - How to fix: "@angular/fire"' has no exported member 'AngularFireModule'.ts(2305) ionic, firebase, angular firestore.d.ts:11:64 - 错误 TS2694:命名空间“admin.firestore”没有导出成员“QueryDocumentSnapshot” - firestore.d.ts:11:64 - error TS2694: Namespace 'admin.firestore' has no exported member 'QueryDocumentSnapshot' Angular 13:命名空间“/node_modules/firebase/compat/index”没有导出成员“用户”。 ts(2694) - Angular 13: Namespace '"/node_modules/firebase/compat/index"' has no exported member 'User'. ts(2694) Firestore AttributeError:模块“firebase_admin”没有属性“firestore” - Firestore AttributeError: module 'firebase_admin' has no attribute 'firestore' 尝试导入错误:“查询”未从“firebase/firestore”导出 - Attempted import error: 'query' is not exported from 'firebase/firestore' “addDoc”不是从“firebase/firestore”导出的 - 'addDoc' is not exported from 'firebase/firestore' Firebase 'collection' 未从 'firebase/firestore' 导出 - Firebase 'collection' is not exported from 'firebase/firestore' Firebase 错误:找不到模块:错误:包路径。 不从包中导出 - Firebase Error : Module not found: Error: Package path . is not exported from package Firebase 错误:找不到模块:错误:Package 路径。 不从 package 导出 - Firebase Error : Module not found: Error: Package path . is not exported from package
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM