Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
firebase仅导入所需的软件包_Firebase_Firebase Authentication_Angularfire - Fatal编程技术网

firebase仅导入所需的软件包

firebase仅导入所需的软件包,firebase,firebase-authentication,angularfire,Firebase,Firebase Authentication,Angularfire,我在Angular 6应用程序中使用firebase,当我使用以下导入时 import { auth, User } from 'firebase'; 我在浏览器控制台中收到以下警告: 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 indi

我在Angular 6应用程序中使用firebase,当我使用以下导入时

import { auth, User } from 'firebase';
我在浏览器控制台中收到以下警告:

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>';
看起来您正在使用Firebase JS SDK的开发版本。
将Firebase应用程序部署到生产环境时,建议只导入
您打算使用的单个SDK组件。
对于模块构建,可以通过以下方式获得
(替换为组件的名称-即身份验证、数据库等):
CommonJS模块:
const firebase=require('firebase/app');
要求('firebase/');
ES模块:
从“firebase/app”导入firebase;
导入“firebase/”;
每当我将导入从“firebase/auth”切换到类似于
import*as auth的内容时

  • 我得到一个不同的错误:
    export'GoogleAuthProvider'(作为'auth'导入)在'firebase/auth'
    中找不到(因为我也在使用
    GoogleAuthProvider
  • auth
    变量不再有它的定义,我无法按CTRL键并查看发生了什么

根据danfri86对此GitHub问题的评论,您应该做以下操作:

从“firebase/app”导入firebase;
导入“firebase/auth”;//这条线很重要
export const googleProvider=new firebase.auth.GoogleAuthProvider();
事实上,这就是警告所说的:

ES Modules:
import firebase from 'firebase/app';
import 'firebase/<PACKAGE>';
ES模块:
从“firebase/app”导入firebase;
导入“firebase/”;

我刚刚测试了它,它没有抛出任何错误。

我刚刚尝试了从'firebase/auth'以身份导入*且控制台中不显示任何错误。如您所述,
从“firebase”导入{auth,User}在控制台中显示警告。我更新了问题。我得到了错误,因为它再也找不到
GoogleAuthProvider
,但我认为包应该是相同的