firebase提供TypeError:必需的glob模式字符串

时间:2018-11-26 22:16:36

标签: firebase firebase-hosting

我目前有一个已部署的Firebase应用程序,现在与节点连接以构建UI。之前,我已将此应用程序与Firebase托管和Firebase实时数据库一起部署,并且没有遇到任何问题。即使从视频“ Firebase Hosting Crash Course-Firecasts”上的“ Node.js应用程序”视频中精确复制示例代码和说明时,在尝试从命令行调用Firebase服务时也会遇到此错误。我正在使用Mac OSX。错误消息如下:

i  functions: Preparing to emulate functions.
i  hosting: Serving hosting files from: public
✔  hosting: Local server: http://localhost:5000
✔  functions: helloWorld: http://localhost:5001/test-setup-5ae3a/us-central1/helloWorld
127.0.0.1 - - [26/Nov/2018:21:53:20 +0000] "GET /__/firebase/init.js HTTP/1.1" 200 - "http://localhost:5000/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36"
TypeError: glob pattern string required
    at minimatch (/usr/local/lib/node_modules/firebase-tools/node_modules/minimatch/minimatch.js:94:11)
    at /usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/middleware/rewrites.js:20:11
    at /usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/middleware/rewrites.js:33:17
    at _run (/usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/activator.js:58:16)
    at /usr/local/lib/node_modules/firebase-tools/node_modules/superstatic/lib/middleware/files.js:117:16
    at tryCatch (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:525:12)
    at invokeCallback (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:538:13)
    at publish (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:508:7)
    at flush (/usr/local/lib/node_modules/firebase-tools/node_modules/rsvp/dist/rsvp.js:2415:5)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)

这是我的firebase.json:

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "rewrites": [
      {
        "sources": "/timestamp",
        "function": "app"
      }
    ],
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ]
  }
}

这是我的functions文件夹中的index.js文档:

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

const app = express();
app.get('/timestamp', (request, responce) => {
  response.send(`${Date.now}`);
});

exports.helloWorld = functions.https.onRequest(app);

1 个答案:

答案 0 :(得分:0)

问题出在这一行:

exports.helloWorld = functions.https.onRequest(app);

应该是:

exports.app = functions.https.onRequest(app);