【问题标题】:Can't serve firebase functions无法提供 Firebase 功能
【发布时间】:2025-12-01 22:40:01
【问题描述】:

我正在尝试从 Firebase Web Codelab 关注 this tutorial,但在第 5 步遇到问题:运行命令 firebase serve 后,我没有得到预期的响应 Listening at http://localhost:5000,但我得到了:

i functions: Preparing to emulate functions. i hosting: Serving hosting files from: ./ + hosting: Local server: http://localhost:5000

这很糟糕,因为没有提供函数,尽管没有提示 ⚠ functions: Failed to emulate api,但它仍然无限期地“准备模拟函数”。

更多信息:CLI Version: 3.18.4 Platform: win32 Node Version: v6.12.3 我已经尝试去 ~/.config/configstore/ 并删除 @Google-Cloud 文件夹以重新启动整个过程。

【问题讨论】:

    标签: firebase localhost google-cloud-functions firebase-cli


    【解决方案1】:

    我很确定您在正确的轨道上,预期消息 (Listening at http://localhost:5000) 和您收到的消息 (hosting: Local server: http://localhost:5000) 之间的差异是因为您使用的是新版本的 CLI (v3. 18.4),但未更新 codelab 章节以反映日志消息中的新更改。

    您可以在显示的源代码firebase-tools v2.2.1 中看到差异

    Listening at http://<HOST>:<PORT>
    

    firebase-tools v3.18.4 中显示

    hosting: Local server: http://<HOST>:<PORT>
    

    对于函数仿真,正如您在第 5 步中一样,您还没有函数,请参阅 codelab 源代码中的functions

    【讨论】: