问题
$ 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!");
});
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/57070483/firebase-serve-only-functions-doesnt-work