功能无法在本地运行的Firebase托管

时间:2018-06-26 23:11:20

标签: firebase firebase-hosting firebase-cli

我创建了一个具有功能的简单动态Firebase托管,部署后一切正常,但在本地提供页面时一切正常。 这是firebase serve

的日志
i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5004

✔  functions: serveLandingPage: http://localhost:5001/zonaskripsi18/us-central1/serveLandingPage

我们看到,控制台和firebase-debug.log中都没有错误日志,但是当我打开http://localhost:5004时,它显示了An internal error occurred while connecting to Cloud Function "serveLandingPage"

这是firebase.json

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ]
  },
  "hosting": {
    "public": "public",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/**",
        "function": "serveLandingPage"
      }
    ]
  }
}

这是屏幕截图: enter image description here enter image description here

2 个答案:

答案 0 :(得分:0)

Firebase最近在其本地服务器上遇到了问题,只需部署它,然后运行它进行测试

答案 1 :(得分:0)

如果您的函数项目是Typescript,那么在为本地主机提供服务之前,您已经将Typescript编译为javascript文件。

cd functions 
tsc