4
$ 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

but when serve hosting will success

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

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

Please help me.

Here is my versions.

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

node -v
v12.3.1

firebase --version
7.1.0

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

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!");
});
yhirochick
  • 93
  • 1
  • 11
  • What exactly are you trying to serve? What's your code? – Doug Stevenson Jul 17 '19 at 15:00
  • Are you using Windows Subsystem for Linux? If so it looks the same as this bug: https://github.com/firebase/firebase-tools/issues/1458 – Sam Stern Jul 17 '19 at 16:04
  • The issue linked mentions WSL 2 and firebase-tools 7.0.2. The issue I'm observing is on WSL 1 and does not occur in 7.0.2 but does occur in 7.1.0. – Raven Jul 17 '19 at 16:16
  • Thank you for your advice every one, I added some environments information.I will try change firebase version. – yhirochick Jul 18 '19 at 04:36

2 Answers2

4

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

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

Raven
  • 1,453
  • 3
  • 18
  • 29
0

See https://firebase.google.com/docs/functions/manage-functions#set_nodejs_version .

Your requested "node" version "8" doesn't match your global version "12"

You should use Node.js 8 or Node.js 10. Not Node.js 12.

At first, check your node version, and you can manage node version using Node Version Manager like a nvm.

zkohi
  • 2,486
  • 1
  • 10
  • 20
  • 1
    This is not likely the problem. This is just an informational message. The real error is the line following it. – Doug Stevenson Jul 17 '19 at 15:00
  • Sorry, I may wrong. The problem may be port 5000 is already used, etc. In any case, more information is needed. – zkohi Jul 17 '19 at 15:24
  • I'm having the same issue and switching to node 10 using `nvm` does not solve this problem. It does appear unrelated to the actual issue. Port 5000 is also not in use. – Raven Jul 17 '19 at 15:40
  • Port 5000 is not likely to be the issue either, as the OP shows that they can run another command that works with port 5000. – Doug Stevenson Jul 17 '19 at 15:52