【问题标题】:Unable to resolve "idb" from "node_modules\@firebase\app\dist\esm\index.esm2017.js"无法从 \"node_modules\\@firebase\\app\\dist\\esm\\index.esm2017.js\" 解析 \"idb\"
【发布时间】:2022-10-26 04:27:41
【问题描述】:

从过去几天开始我就面临一个问题,但无法解决 谁能帮助我让它有效地工作

此外,根据类似站点上的其他解决方案,还将 firebase 降级到 9.6.11。


import firebase from "firebase/compat/app";
import "firebase/compat/auth";
import "firebase/compat/firestore";

// Your web app's Firebase configuration
const firebaseConfig = {
  apiKey: ".......................",
  authDomain: ".......................",
  projectId: ".......................",
  storageBucket: ".......................",
  messagingSenderId: ".......................",
  appId: "......................."
};

// Initialize Firebase
let app;
if (firebase.apps.length === 0) {
  app = firebase.initializeApp(firebaseConfig);
} else {
  app = firebase.app()
}

const auth = firebase.auth()

export { auth };````

【问题讨论】:

    标签: android firebase firebase-realtime-database expo


    【解决方案1】:

    问题解决了 谢谢。 在你项目的根目录下新建一个文件metro.config.js,并在里面添加代码sn-p。

    const { getDefaultConfig } = require("@expo/metro-config");
    
    const defaultConfig = getDefaultConfig(__dirname);
    
    defaultConfig.resolver.assetExts.push("cjs");
    
    module.exports = defaultConfig;
    
    

    【讨论】:

      【解决方案2】:

      地铁回购中有一个问题未解决脸书/地铁#535

      将其添加到我的 Metro 配置后,构建对我来说再次正常工作:

      resolver: {
          sourceExts: ['js', 'json', 'ts', 'tsx', 'cjs'],
        },
      

      【讨论】:

        【解决方案3】:

        虽然最上面的解决了这个问题。如果您想了解更多,请点击此官方链接 - https://docs.expo.dev/guides/using-firebase/#step-3-configure-metro

        或者只是将代码粘贴到新文件中Metro.config.js在您的根项目文件夹中 -

        const { getDefaultConfig } = require('@expo/metro-config');
        const defaultConfig = getDefaultConfig(__dirname);
        defaultConfig.resolver.assetExts.push('cjs');
        module.exports = defaultConfig;
        

        【讨论】:

          猜你喜欢
          • 2022-09-27
          • 2022-06-27
          • 1970-01-01
          • 1970-01-01
          • 2021-11-17
          • 2020-07-10
          • 2019-07-15
          • 1970-01-01
          • 2021-01-13
          相关资源
          最近更新 更多