Firebase function deployment completed, however not appearing in the console

This particular question is similar to question 44799104, but the difference lies in my inclusion of index.js (and the sole answer provided there was not helpful, even though I have included 'exports').

In summary, I have successfully deployed my function,

https://i.sstatic.net/8038s.png

However, it does not appear in the console. Can someone point out where I might be making a mistake? Below is my index.js:

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

admin.initializeApp(functions.config().firebase);

var delayInMilliseconds = 5000;

exports.copyRoom = functions.database.ref('/RoomsOwn/${AuthUid}').onWrite((event) => {

    var uid = event.params.AuthUid;
    console.log('AuthID: ' + uid);
    var object = event.data.val();
    console.log('Whole Object: ', object);

    setTimeout(function() {
    return admin.database.ref('/RoomsOthers/${uid}').set(object);
    }, delayInMilliseconds);

  });

Answer №1

The function you attempted to deploy was not actually deployed when you ran the command firebase deploy. If the deployment had been successful, the name of the function would have been shown in the Firebase CLI output.

To ensure successful deployment, be sure to:

  1. Save the file containing the function that you want to deploy.
  2. Place the file in the correct directory. In JavaScript projects, this is typically functions/index.js
  3. Deploy the right project from the appropriate directory.

Answer №2

For my situation, all I needed to do was navigate into the functions directory before deploying. Make sure you see this in your output:

https://i.sstatic.net/Nwux9.png

Answer №3

After troubleshooting, I discovered that the issue lied within the function name itself. I had defined my function as fooBar, but mistakenly used foobar elsewhere in my code.

firebase deploy --only functions:foobar // Incorrect
firebase deploy --only functions:fooBar // Correct

Answer №4

During my experience, I faced an issue while working with Typescript where I had imported an interface from a location outside of the function's directory. After removing that import, my deployment went smoothly as planned.

Answer №5

It slipped my mind to send back the firebase function from within a wrapping function.

export const myWrapper = (database: any, url: any) => {
//Make sure to include the return keyword here!!
  return functions.https.onRequest((req, res) => { }

}

Hopefully this tip proves useful for someone in the future.

Answer №6

The issue I encountered was due to importing types/interfaces from a higher level directory than the functions directory, causing the index.js file to be located differently during the build process.

To resolve this, I needed to navigate to the functions directory's package.json file and update the main field to point to the correct location of index.js within the directory.

After making this adjustment, the deployment went smoothly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Passport.js does not provide authentication for server-side asynchronous requests

Recently, I configured Passport.js with the local-strategy on my express server. Interestingly, when I am logged in and send an asynchronous request within NextJS's getInitialProps, it allows the GET request through client-side rendering but not serv ...

Tips for resolving the error message "TypeError: props.scoreboard.map is not a function" that only occurs after refreshing the page

I'm encountering an unusual problem while attempting to iterate over the response from my backend. Despite logging the response as an array, I still face issues similar to those where the response is not considered an array. I am passing the scoreboa ...

Having trouble understanding how to display an HTML file using Next.JS?

Currently, I am working on a project that involves utilizing Next.JS to develop a webpage. The main goal is to display a PDF file on the left side of the screen while integrating Chaindesk on the right side to create a chat bot capable of extracting inform ...

I am a newcomer to Stack Overflow and I am facing difficulty in getting my form to submit successfully

Excuse any errors as I am new to this. I am facing an issue where my form is not submitting anything in the console. Could it be because my entire HTML file is within a return statement from a JavaScript function? I assumed it would work since I imported a ...

Display the MediaStream on a WebGLRenderer

It may sound a bit unusual, but how can you display a video stream var videoStream = new MediaStream(stream.getVideoTracks()); using var renderer = new THREE.WebGLRenderer({antialias: true, alpha: true}); renderer.setSize(640, 480); ...

Displaying Image Previews in Rails View Using JavaScript

I am working on a functionality where I have a text_field that contains the URL of an image. The goal is to load this URL into an img tag and update the preview image when the user changes the URL in the text field. Below is the relevant erb code for the ...

splitting the responsibilities between two classes

Hey there, I'm currently pondering over whether to implement the separation of concerns concept in two separate classes. Firstly, I have my Match class: class Match { constructor (players) { this.id = uuid.v4().toString(); this.playe ...

Encountering a CORS issue when utilizing Stripe with various servers while navigating with a Router

I have a router that utilizes Router.express(). The backend operates on port 5000, while the frontend runs on port 3000. Within the frontend folder, there is a button with a fetch request (http://localhost:5000/create-checkout-session). In the backend, the ...

IDEA 2021.2 NPM SCRIPTS: Looks like there are no scripts available

Searching through the npm scripts, I am unable to locate any, however package.json does contain: ...

What are the steps for utilizing a button instead of an input field that is not within a form?

I need assistance with setting up a navbar with a button that will submit a form in the body with the ID of album_form. Can anyone provide suggestions for what to include in the onclick attribute to achieve this functionality? <body> <header& ...

Connect the visibility of one object to the visibility of another object

How can I make DOM-element a visible when DOM-element b is visible, and hidden when b is hidden using jQuery? I'm seeking a solution to achieve this effect. Is there a way to accomplish this with jQuery? Thank you in advance! To clarify my question ...

As you scroll, the top block in each of the three columns will remain fixed within its

I need assistance with a problem involving three columns and multiple blocks within each column. Specifically, I want the first block in each column to remain fixed at the top when scrolling. However, once you reach the bottom of each column, the first blo ...

How can I represent non-ASCII characters in Java Script using encoding?

Imagine if ch = á the desired result is = \u00e1 however the current output = %E1 when escape(ch) is used and current output = %C3%A1 when encodeURIComponent(ch) is used I am working with an API that supports Unicode characters. ...

"Mesmerizing Motion: The World of Three

Exploring the world of ThreeJS, I am experimenting with the concept of incorporating multiple objects in a scene and implementing transitions on these objects with the click of a button. While I have grasped the idea of working with multiple objects and a ...

I'm having trouble displaying the content of my list items within the div

In my code, I have a class called "ignicoes" that includes a list as one of its attributes. This list contains other attributes such as dispositivo, latitude, longitude, and more. My goal is to retrieve the contents of this list and display them within my ...

The OpenWeatherMap API is displaying 'undefined' as a response

I've been encountering some issues with my weather app project due to lack of clarity in my previous questions. To be more specific, every time I attempt to retrieve weather information in JSON format using the fetch method, it keeps returning undefin ...

Adjusting background position using incremental changes through JavaScript

Although I have a strong background in PHP coding, using javascript is a new venture for me so I hope this question doesn't sound naive. My objective is to create a button that, when clicked, shifts the background-position of a specified DIV object b ...

Trouble with loading static files correctly on React Js front end and Express backend

My front end React app has the following routes: var React = require("react"); var ReactDOM = require("react-dom"); var {Route, Router, IndexRoute, browserHistory} = require("react-router"); var Main = require("Main"); var BlogList = r ...

Unable to retrieve the user ID from a Discord username using Discord JS

let string = `${args[1]} ${args[2]}` console.log(string) const idofuser = client.users.cache.find((u) => u.username === `${string}`).id I am facing an issue with DiscordJS where it says "cannot read property 'id' of undefined" when trying to ...

I am looking for a setup where a checkbox triggers the opening of the next accordion

I am encountering a problem with the bootstrap accordion feature. I am looking to have the first accordion nested inside a checkbox, so that when the checkbox is clicked, the next accordion automatically opens. If the checkbox is not clicked, the next ac ...