I am trying to deploy my Node.js application in firebase but when I run the command it results in the error Error:
runtime field is required but was not found in firebase.json.
I tried running the command firebase serve --only functions,hosting
and everything works fine locally so I would like to deploy and provide the link to my colleagues for the user testing but I am unable to do it using the firebase deploy
command.
I tried adding the command to my firebase.json
file but still no luck. Here is my original firebase.json
file:
{
"hosting": {
"public": "public",
"rewrites": [
{
"source": "**",
"function": "app"
}
]
}
}
After getting the error I changed to this:
{
"hosting": {
"public": "public",
"runtime": "nodejs10",
"rewrites": [
{
"source": "**",
"function": "app"
}
]
}
}
Still getting the error, I am bit confused where exactly I need to add the command "runtime": "nodejs10",
. I tried looking but could not find any relevant article on the similar issue, can anyone please help me.
The error message says to add it to the "functions" section. You're adding it to the "hosting" section, which won't work. The runtime choice is made for Cloud Functions, not Firebase Hosting. They are different products with different configuration.
The message is also not entirely accurate about what to add.
Add the runtime to the functions section as discussed in the documentation:
{
"functions": {
"engines": {"node": "10"}
}
}
To set the runtime ,set the version in the engines
field in the package.json file that was created in your functions/ directory during initialization. For example, to use only version 10, edit this line in package.json:
"engines":{"node":"10"}
The engines field is required; it must specify one of the supported Node.js versions in order for you to deploy and run functions. Currently, firebase init functions sets this field to node 10
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With