无法将函数部署到 firebase,因为 "admin.databse is not a function"

Can't deploy a function to firebase because "admin.databse is not a function"

我尝试将此功能部署到 firebase:

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

const ref = admin.databse().ref();

exports.creatUserAccount = functions.auth.user().onCreat(event =>{
    const uid = event.data.uid;
    const newUserRef = ref.child('/users/${uid}');
    return newUserRef.set({
        uid: uid
    });
});

但是 Node.js 给我扔了这个:"admin.databse is not a function"。我该怎么办?

你打错了,admin.databse().ref();需要admin.database().ref();

database()是实例的函数。
所以你应该像下面这样使用。

admin.initializeApp(functions.config().firebase);

const ref = admin.databse().ref();

至 =>

var instance = admin.initializeApp(functions.config().firebase);

const ref = instance.database().ref();