Firebase无法了解要部署的目标

Him*_*shu 9 firebase

在部署以下hello-world等效代码时,我得到最后显示的错误: -

$ ls -lR
.:
total 8
-rw-r--r-- 1 hgarg hgarg    3 Aug 29 14:55 firebase.json
drwxr-xr-x 2 hgarg hgarg 4096 Aug 29 11:56 functions

./functions:
total 4
-rw-r--r-- 1 hgarg hgarg 1678 Aug 29 11:56 index.js
Run Code Online (Sandbox Code Playgroud)

firebase.json看起来像这样: -

{}
Run Code Online (Sandbox Code Playgroud)

和index.json这样: -

'use strict';

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

exports.search = functions.https.onRequest((req, res) => {
  if (req.method === 'PUT') {
    res.status(403).send('Forbidden!');
  }

  var category = 'Category';
  console.log('Sending category', category);
  res.status(200).send(category);
});
Run Code Online (Sandbox Code Playgroud)

但部署失败: -

$ firebase deploy

Error: Cannot understand what targets to deploy. Check that you specified valid targets if you used the --only or --except flag. Otherwise, check your firebase.json to ensure that your project is initialized for the desired features.

$ firebase deploy --only functions

Error: Cannot understand what targets to deploy. Check that you specified valid targets if you used the --only or --except flag. Otherwise, check your firebase.json to ensure that your project is initialized for the desired features.
Run Code Online (Sandbox Code Playgroud)

aof*_*dev 15

最好使用默认选项预填充firebase.我选择我只想使用主机firebase.json应该使用默认主机选项创建.

{
  "hosting": {
    "public": "public"
  }
}
Run Code Online (Sandbox Code Playgroud)

或者你再试firebase init一次.


Rax*_*nki 7

面临类似的问题.在firebase.json文件中(在托管参数中),我们必须提供我们要部署的目录的名称(在我的情况下,我已经在目录中,我想部署,因此我把"."放在托管中规格).它解决了我的错误.

{
  "hosting": {
    "public": ".",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)


Nat*_*tch 5

我在运行时遇到了这个问题:

firebase emulators:exec --only firestore 'npm tst'

问题是 onfirebase.json必须具有您想要的模拟器的属性。所以就我而言,我添加了一个"firestore": {}firebase.json工作了。