找不到模块:无法解析“firebase" [英] Module not found: Can't resolve 'firebase' in
问题描述
之后:npm i firebase
After: npm i firebase
我正在从 firebase 本身导入 firebase &不是来自文件
I'am importing firebase from firebase itself & not from a file
从 'firebase' 导入 firebase; >在 firebase.js 文件中<
import firebase from 'firebase'; >in firebase.js file<
终端错误>>./src/firebase.js未找到模块:无法解析 'C:UsersHomeDocumentsdsneDocuments....' 中的 'firebase'
error in terminal>> ./src/firebase.js Module not found: Can't resolve 'firebase' in 'C:UsersHomeDocumentsdsneDocuments..........'
推荐答案
npm i firebase
现在安装 v9 Modular SDK,因此您不能使用旧的导入.尝试将您的代码重构为:
npm i firebase
now installs v9 Modular SDK so you cannot used the old imports. Try refactoring your code to this:
import { initializeApp } from 'firebase/app';
const firebaseConfig = {
//...
};
const app = initializeApp(firebaseConfig);
如果您想使用旧语法,请将导入更改为兼容库:
If you want to use older syntax then change your imports to compat libraries:
import firebase from "firebase/compat/app"
import "firebase/compat/auth"
import "firebase/compat/firestore"
// other services is needed
您可以在文档
这篇关于找不到模块:无法解析“firebase"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!