小编Chr*_*dal的帖子

无法使用 AngularFire 将 Firebase 函数更新到 Angular Universal 应用程序中的节点 12

我按照本教程将 Angular Universal 部署到 firebase 函数并使用 Firebase 进行部署:https ://medium.com/@chris.duebbert/angular-9-universal-firebase-deploy-8d8d47244e1c

一切正常,直到我将 AngularFireModule 添加到我的 app.module.ts。然后,当我使用节点 12 运行“ng deploy”时,我在“ssr”函数的日志中收到以下错误:

提供的模块无法加载。您的代码中是否存在语法错误?详细的堆栈跟踪:ReferenceError: globalThis is not defined

当我尝试将本地节点版本设置为 10 时,我直接在终端中收到相同的错误。

显然,Firebase 使用 globalThis ,这需要节点版本 12(Angular 11 在 SSR @nguniversal/express-engine ReferenceError: globalThis is not defined 上运行)。我在 /functions/package.json 中添加了以下内容:

app.module.ts

    "engines": {
        "node": "12"
      },
Run Code Online (Sandbox Code Playgroud)

我可以为节点版本输入任意数字,并且我的 SSR 功能仍在使用节点 10 进行部署,并且“globalThis”错误仍在继续。我正在使用 Firebase 的 Blaze 计划。这是我的 app.module.ts:


    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule.withServerTransition({ appId: 'serverApp' }),
        AppRoutingModule,
        NoopAnimationsModule,
        FormsModule,
        NgxTwitterTimelineModule,
        AngularFireModule.initializeApp(config),
      ],
      providers: [],
      bootstrap: …
Run Code Online (Sandbox Code Playgroud)

node.js firebase angularfire angular-universal

4
推荐指数
1
解决办法
602
查看次数