【问题标题】:Warning "It looks like you're using the development build of the Firebase JS SDK" in Angular firebase appAngular firebase 应用程序中的警告“看起来您正在使用 Firebase JS SDK 的开发版本”
【发布时间】:2020-09-24 22:22:12
【问题描述】:

我在我的 Angular 项目中使用 Angular Fire sdk。但它会触发以下警告。我搜索了这个问题并得到了答案。但这些答案不适用于 Angular 项目。

It looks like you're using the development build of the Firebase JS SDK.
When deploying Firebase apps to production, it is advisable to only import
the individual SDK components you intend to use.

For the module builds, these are available in the following manner
(replace <PACKAGE> with the name of a component - i.e. auth, database, etc):

CommonJS Modules:
const firebase = require('firebase/app');
require('firebase/<PACKAGE>');

ES Modules:
import firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

Typescript:
import * as firebase from 'firebase/app';
import 'firebase/<PACKAGE>';

我的应用模块如下所示。

import {AngularFireModule} from '@angular/fire';
import {AngularFireAuthModule} from '@angular/fire/auth';

imports:[
   ...
    AngularFireModule.initializeApp(environment.firebaseConfig),
    AngularFireAuthModule,
]

我想在我的 Angular 项目中停止这个警告。

【问题讨论】:

  • 您确定是您使用 firebase 导入的唯一文件吗?我设法删除了该警告,只是按照我正在使用 firebase 的任何文件中的建议写入

标签: angular firebase configuration angularfire2


【解决方案1】:

终于找到了解决办法。

这是导入 firebase 的错误方式

import {auth} from 'firebase';

这是导入 firebase 的正确方法

import * as firebase from 'firebase/app';

【讨论】:

    猜你喜欢
    • 2023-03-06
    • 1970-01-01
    • 2021-05-03
    • 2018-11-22
    • 1970-01-01
    • 1970-01-01
    • 2019-01-17
    • 1970-01-01
    • 2019-09-16
    相关资源
    最近更新 更多