简体   繁体   English

Firebase 函数正在部署,但未显示在控制台中

[英]Firebase function deploying, but not showing up in console

This question is essentially the same as question 44799104 , only that I provide my index.js (and the only answer there was not helpful, as I do include 'exports').这个问题与问题44799104基本相同,只是我提供了我的 index.js(并且唯一的答案没有帮助,因为我确实包含了“导出”)。

In short, I have deployed my function successfully,总之,我已经成功部署了我的功能,

控制台输出

but it does not show in the console.但它没有显示在控制台中。 Where am I going wrong?我哪里错了? Here is my index.js:这是我的 index.js:

const functions = require('firebase-functions');
const admin = require('firebase-admin');

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

var delayInMilliseconds = 5000;


exports.copyRoom= functions.database.ref('/RoomsOwn/${AuthUid}').onWrite((event) => {

    var uid = event.params.AuthUid;
    console.log('AuthID: ' + uid);
    var object = event.data.val();
    console.log('Whole Object: ', object);

    setTimeout(function() {
    return admin.database.ref('/RoomsOthers/${uid}').set(object);
    }, delayInMilliseconds);

  });

You didn't actually deploy that function when you ran firebase deploy . 在运行firebase deploy时,您实际上没有部署该功能。 If you had successfully deployed it, the name of the function would have appeared in the Firebase CLI output. 如果您已成功部署它,则该功能的名称将出现在Firebase CLI输出中。

Make sure you: 确保你:

  1. Actually saved the file with the function you're trying to deploy. 实际上使用您尝试部署的功能保存了文件。
  2. The file is in the correct directory. 该文件位于正确的目录中。 For JavaScript projects, the default is functions/index.js 对于JavaScript项目,默认值为functions/index.js
  3. Are deploying the correct project from the correct directory. 是否从正确的目录部署正确的项目。

In my case I just had to cd into the functions folder before deploy. 在我的情况下,我只需要在部署之前进入函数文件夹。 Note that you should be getting this in your output: 请注意,您应该在输出中获取此信息:

云功能输出包括功能url和关于打包和上传功能文件夹的步骤

For me the problem was in the name of the function.对我来说,问题出在函数的名称上。 My function name was fooBar but I was using foobar .我的函数名称是fooBar但我使用的是foobar

firebase deploy --only functions:foobar // Incorrect
firebase deploy --only functions:fooBar // Correct

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM