"firebase服务-仅功能"不起作用 [英] "firebase serve --only functions" doesn't work

查看:73
本文介绍了"firebase服务-仅功能"不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ firebase serve --only functions
⚠  Your requested "node" version "8" doesn't match your global version "12" 
Error: TIMEOUT: Port 5000 was not active within 30000ms

但是当服务托管会成功

$ firebase serve --only hosting
i  hosting: Serving hosting files from: dist/chongsheng-jp
✔  hosting: Local server: http://localhost:5000

我以为我没有编译index.ts,而是按照Firebase官方文档尝试了 npm run serve ,但这不起作用.

I thought that I didn't compile index.ts, I tried npm run serve following firebase official doc but It doesn't work.

请帮助我.

这是我的版本.

"firebase-admin": "^8.0.0",
"firebase-functions": "^3.1.0"

node -v
v12.3.1

firebase --version
7.1.0

我在WSL(不是wsl2)上使用ubuntu,版本低于

I use ubuntu on WSL(not wsl2) and version is below

lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:        18.04
Codename:       bionic

这是我的代码(index.ts)

and here is my code (index.ts)

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

// Create and Deploy Your First Cloud Functions
// https://firebase.google.com/docs/functions/write-firebase-functions

exports.helloWorld = functions.https.onRequest((request, response) => {
  response.send("Hello from Firebase!");
});

推荐答案

我在新项目和现有项目中都遇到了同样的问题.它与节点版本,所使用的端口或项目代码无关.恢复到以前的版本对我有用:

I'm just seeing the same issue on new and on existing projects. It's not related to the node version, the port being used or the project code. Reverting to the previous release worked for me:

npm i -g firebase-tools@7.0.2

v7.1.0 版本中的内容必须具有导致了这个问题.

Something in the v7.1.0 release must have caused this issue.

这篇关于"firebase服务-仅功能"不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆