Firebase cannot understand what targets to deploy
Solution 1
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.
Solution 2
Faced similar issue. In firebase.json file (in hosting parameter), we have to give the name of directory that we want to deploy (in my case, I was already in the directory, which I wanted to deploy, hence I put "." in hosting specification). It solved the error for me.
{
"hosting": {
"public": ".",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
Solution 3
I was facing this issue when running:
firebase emulators:exec --only firestore 'npm tst'
The problem was that on firebase.json
must have a property for the emulator you want. So in my case I added a "firestore": {}
on firebase.json
and worked.
Solution 4
Firebase reads package.json to read details of the functions target. This file was missing from my project directory, as I had moved files around after doing an init.
Creating a clean directory and doing a firebase init functions inside it created all the required files and folders to get started.
Solution 5
I think you are missing on one of the following things -
a) you should run firebase init outside of the main project where index.html is. b) select hosting option after running firebase init by pressing SPACE c) Please give folder name which contain index.html in it.
And your project will be up running.
Himanshu
Updated on June 28, 2022Comments
-
Himanshu about 2 years
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.
-
Francis Rodrigues over 6 yearsFor deploy reactjs app, it must be set
public
tobuild/.
. That's enough. -
Tien Do about 6 years"hosting.public" is actually the root directory of web app. So "public" value is not required. Documentation needs to make it clear.
-
Tien Do about 6 years@FrancisRodrigues It must be set to where you store index.html (or any start page of the website).
build/.
is your only case, React app often created withdist
folder for output files for example. -
EdwinCab about 2 yearscurrently, if you run firebase init the wizard will create: "database": { "rules": "database.rules.json" } in the firesabe.json, so the right command to deploy the rules is firebase deploy --only database: rules