【问题标题】:Firebase firestore not working with Angular 10 and SSR or prerenderFirebase firestore 不适用于 Angular 10 和 SSR 或预渲染
【发布时间】:2020-07-31 16:50:08
【问题描述】:

当我尝试使用 Angular 10 构建新项目时,仅添加从 @angular/fire/firestore 模块导入的 AngularFireModule 无法构建为预渲染或使用 build:ssr 命令。

 "dependencies": {
"@angular/animations": "~10.0.2",
"@angular/common": "~10.0.2",
"@angular/compiler": "~10.0.2",
"@angular/core": "~10.0.2",
"@angular/fire": "^6.0.2",
"@angular/forms": "~10.0.2",
"@angular/platform-browser": "~10.0.2",
"@angular/platform-browser-dynamic": "~10.0.2",
"@angular/platform-server": "~10.0.2",
"@angular/router": "~10.0.2",
"@nguniversal/express-engine": "^10.0.1",
"express": "^4.15.2",
"firebase": "^7.16.0",
"rxjs": "~6.5.5",
"tslib": "^2.0.0",
"zone.js": "~0.10.3"

在 app.module.ts 中

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { AngularFireModule } from '@angular/fire';
import { AngularFirestoreModule } from '@angular/fire/firestore';
import { AngularFireStorageModule } from '@angular/fire/storage';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AboutComponent } from './about/about.component';
import { environment } from 'src/environments/environment';

@NgModule({
  declarations: [AppComponent, AboutComponent],
  imports: [
    BrowserModule.withServerTransition({ appId: 'serverApp' }),
    AppRoutingModule,
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFireAuthModule, 
    AngularFireStorageModule, 
    //this module failed to build
    //   AngularFirestoreModule, 
  ],
  providers: [],
  bootstrap: [AppComponent],
})

错误信息:

./node_modules/@grpc/grpc-js/build/src/channel-credentials.js 中的错误 未找到模块:错误:无法解析“C:........\monApp\node_modules@grpc\grpc-js\build\src”中的“google-auth-library”

似乎 grpc 模块中是否存在 angular 10 的问题...

【问题讨论】:

    标签: node.js angular firebase grpc server-side-rendering


    【解决方案1】:

    希望您在提出这个问题后找到了解决方案。

    当我遇到同样的问题时我做了什么?只需安装包 google-auth-library :

    npm install google-auth-library --save
    

    然后,应该没问题。

    PS:我不知道这个问题的根本原因,但我知道这个解决方法有效。

    【讨论】:

      猜你喜欢
      • 2020-12-16
      • 1970-01-01
      • 2022-10-07
      • 2019-11-23
      • 2019-12-19
      • 2022-01-06
      • 2020-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多