1

I've been following the codelabs tutorial here to deploy my first functions to firebase. I've made it to step 8 of the tutorial ("Welcome new users").

The deploy looks successful when I run firebase deploy --only functions from within the functions subdirectory:

Marks-MacBook-Air-3:functions mf$ firebase deploy --only functions

=== Deploying to 'friendlychat-21221'...

i deploying functions Running command: npm --prefix "$RESOURCE_DIR" run lint

functions@ lint /Users/mf/Desktop/friendlychat-web/cloud-functions-start/functions eslint .

✔ functions: Finished running predeploy script. i functions: ensuring necessary APIs are enabled... ✔ functions: all necessary APIs are enabled i functions: preparing functions directory for uploading...

✔ Deploy complete!

But looking at my firebase dashboard, it doesn't look like they deployed after all: enter image description here

I'm not even sure where to begin troubleshooting, since the logs in the cloud functions tab is empty.

Has anyone encountered this before and/or have a good troubleshooting strategy?

Update 1:15 PM Friday 25 May, 2018: This is my index.js file in the functions subdirectory:

const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); // TODO(DEVELOPER): Write the addWelcomeMessages Function here. // Adds a message that welcomes new users into the chat. exports.addWelcomeMessages = functions.auth.user().onCreate(user => { console.log('A new user signed in for the first time.'); const fullName = user.displayName || 'Anonymous'; // Saves the new welcome message into the database // which then displays it in the FriendlyChat clients. return admin.database().ref('messages').push({ name: 'Firebase Bot', photoUrl: '/images/firebase-logo.png', // Firebase logo text: `${fullName} signed in for the first time! Welcome!`, // Using back-ticks. }).then(() => { console.log('Welcome message written to database.'); }); }); // TODO(DEVELOPER): Write the blurOffensiveImages Function here. // TODO(DEVELOPER): Write the sendNotifications Function here. 

Here are the contents of the functions subdirectory:

enter image description here

6
  • 1
    Make sure you are exporting the function you are trying to deploy in your index.js file. Commented May 25, 2018 at 20:12
  • @fatemefazli I added index.js above. I believe that I am exporting. Can you confirm that the above is what you meant? Commented May 25, 2018 at 20:17
  • i mean making sure the index.js file containing all your functions are saved on the "functions" folder inside the project folder. Commented May 25, 2018 at 20:26
  • @fatemefazli gotcha. Yup. Index.js is in there (updated) Commented May 25, 2018 at 20:32
  • emmm it seems OK, consider that Deploying functions extremely slow. Commented May 25, 2018 at 20:37

2 Answers 2

1

I ended up getting it to work after changing two things (and I'm not sure which one fixed this issue; perhaps both):

  1. run npm install from inside the functions directory before you deploy the functions (which should be done in the parent directory).
  2. Be aware that when you run firebase init and cause an overwrite of your index.js file, that file may just have a commented out 'helloWorld' function...
Sign up to request clarification or add additional context in comments.

Comments

0

Try Firebase list to list all the project that you have in firebase under the signed in account and see if the project you are deploying to shows up. In the case where it doesn't show try this:

  • firebase logout && firebase login
  • firebase list
  • firebase use <alias_or_project_id>
  • firebase deploy --only functions or firebase deploy --only functions:<function_name>

Hope this helps!

2 Comments

I can confirm that my project is the current project. No change in behavior, unfortunately.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.