Skip to content
Advertisement

There was an error deploying functions. Failed to update function app in region us-central1

This is my first time trying to deploy a function firebase function. I’ve written an API and I want to create a firebase function and use it.

In my project everything works on localhost and even worked when I did firebase serve --only functions, hosting.

Since I’m only using hosting and functions I didn’t do the initializeApp(firebaseConfig) thing of firebase config (not sure if this is required).

My functions/index.js is:

JavaScript

I’ve pasted this code manually from the index.js that I have in the main project folder (outside functions) and inside the function folder I’ve another index.js, and package.json files which were auto-generated and I have added dependencies as I had in the package.js on outside of the functions folder. Then inside the functions folder, I did npm install.

Here is my functions/package.json file:

JavaScript

Then the only firebase.json file has these settings:

JavaScript

When I do firebase deploy (that deploys the functions and hosting) or firebase deploy --only functions I get an error from which I’ve taken the last 10 lines:

JavaScript

I’ve tried different solutions with a similar title, but nothing works so far. I have also tried installing packages again in the functions folder, but nothing is wrong for me.

Advertisement

Answer

You can’t have files outside the functions folder. Only what’s in the functions folder gets deployed. Move it inside of your functions folder.

JavaScript

Also, functions.https.onRequest handles parsing the body of incoming requests, so using any body parsers will likely lead to errors and you should remove it.

Advertisement