Firebase cannot understand what targets to deploy

0

Issue

When deploying the following hello-world equivalent code I get the error shown in the end:-

$ 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

firebase.json looks like this:-

{}

and index.json like this:-

'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);
});

But deploying fails:-

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

Solution

it would be better to pre-populate the firebase with the default options. I choose that I wanted to use only hosting the firebase.json should have be created with the default hosting option.

{
  "hosting": {
    "public": "public"
  }
}

or you try run firebase init again.

Answered By – aofdev

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More