【发布时间】:2021-08-05 20:15:05
【问题描述】:
我很难正确导入 firebase SDK。我使用 Vue3 并通过 yarn add firebase 安装了 firebase
这是我的 firebase.js 文件:
import firebase from 'firebase/app';
但是,这会导致以下错误:1:1 error 'firebase/app' should be listed in the project's dependencies. Run 'npm i -S firebase/app' to add it import/no-extraneous-dependencies
import firebase 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';
所以,第一种方法似乎是推荐的,但它不适合我。我做错了什么?
【问题讨论】:
-
您好,使用
require方式获取firebase。