Uncaught Error: Service database is not available firebase javascript

Uncaught Error: Service database is not available firebase javascript

我试图在 firebase 中访问我的实时数据库,但它向我显示此错误 Uncaught Error: Service database is not available。我搜索了这可能意味着什么,但我找不到任何有用的东西或解决方案。

这是我的代码:

window.addPerson = addPerson;

const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const userVar = urlParams.get('user')

const userVarSplitted = userVar.split('#')
const userVarFormatted = userVarSplitted[0] + ":" + userVarSplitted[1]

// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.6.4/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/9.6.4/firebase-analytics.js";
import { getDatabase, ref, set } from "https://www.gstatic.com/firebasejs/9.1.0/firebase-database.js";
// TODO: Add SDKs for Firebase products that you want to use
// https://firebase.google.com/docs/web/setup#available-libraries

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const firebaseConfig = {MY FIREBASE CONFIG};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
if (app.length === 0) {
    console.log("no firebas app")
}else{
    console.log("initialized")
}
const analytics = getAnalytics(app);
const database = getDatabase(app);

function addPerson() {
    set(ref(database, "verified/" + userVarFormatted), {
        name: userVarSplitted[0],
        discriminator: userVarSplitted[1]
    });

    console.log("added")

PS:脚本类型设置为模块化

您知道错误的含义以及发生了什么吗?

您使用的是不同版本的 Firebase SDK。我也会将数据库导入更新到版本 9.6.4,以便所有 Firebase SDK 版本都相同。