【问题标题】:Importing "firebase/app" Module not found: Error: Default condition should be last one导入 \"firebase/app\" 找不到模块:错误:默认条件应该是最后一个
【发布时间】:2023-02-04 02:41:04
【问题描述】:

嗨,我开始使用 webpack 和 firebase。每当我这样做时:

import { initializeApp } from "firebase/app";

这是错误:

文件结构:

索引.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WElcome</title>
    <script src="./main.js"></script>
</head>
<body>
    Welcome
</body>
</html>

索引.js:

import { initializeApp } from "firebase/app";

包.json:

{
  "name": "dark",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack --mode development"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^5.75.0",
    "webpack-cli": "^5.0.1"
  },
  "dependencies": {
    "firebase": "^9.17.0"
  }
}

我已经尝试重新做一遍,但是我在这个文件夹中安装了带有 npm i firebase 的 firebase,并且总是给我同样的错误。我缺少什么?

【问题讨论】:

    标签: javascript node.js firebase webpack webpack-dev-server


    【解决方案1】:

    看起来 9.17.0 有问题,同一个应用程序与 9.16 一起工作,自从我用 9.17.0 测试后就不再工作了

    【讨论】:

      猜你喜欢
      • 2023-02-04
      • 2021-10-25
      • 2021-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      相关资源
      最近更新 更多