1

I am having the hardest of times just trying to get through the cloud functions tutorial here. Every time I try to do firebase deploy --only functions, I always get an error. My firebase-debug.log looks like this

[debug] [2020-05-05T23:45:15.510Z] ----------------------------------------------------------------------
[debug] [2020-05-05T23:45:15.514Z] Command:       /usr/local/bin/node /usr/local/bin/firebase deploy --only functions
[debug] [2020-05-05T23:45:15.515Z] CLI Version:   6.3.0
[debug] [2020-05-05T23:45:15.515Z] Platform:      darwin
[debug] [2020-05-05T23:45:15.515Z] Node Version:  v8.17.0
[debug] [2020-05-05T23:45:15.515Z] Time:          Tue May 05 2020 19:45:15 GMT-0400 (EDT)
[debug] [2020-05-05T23:45:15.515Z] ----------------------------------------------------------------------
[debug] 
[debug] [2020-05-05T23:45:15.532Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-05-05T23:45:15.533Z] > authorizing via signed-in user
[debug] [2020-05-05T23:45:15.533Z] [iam] checking project cloud-functions-demo-5b1c8 for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2020-05-05T23:45:15.535Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2020-05-05T23:45:15.535Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token  
 <request body omitted>
[debug] [2020-05-05T23:45:15.672Z] <<< HTTP RESPONSE 200
[debug] [2020-05-05T23:45:15.684Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/cloud-functions-demo-5b1c8:testIamPermissions  

[debug] [2020-05-05T23:45:15.818Z] <<< HTTP RESPONSE 200
[debug] [2020-05-05T23:45:17.852Z] TypeError: Cannot read property 'wanted' of undefined
    at /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
[error] 
[error] Error: An unexpected error has occurred.
[debug] [2020-05-05T23:45:48.671Z] ----------------------------------------------------------------------
[debug] [2020-05-05T23:45:48.674Z] Command:       /usr/local/bin/node /usr/local/bin/firebase deploy --only functions
[debug] [2020-05-05T23:45:48.675Z] CLI Version:   6.3.0
[debug] [2020-05-05T23:45:48.675Z] Platform:      darwin
[debug] [2020-05-05T23:45:48.675Z] Node Version:  v8.17.0
[debug] [2020-05-05T23:45:48.675Z] Time:          Tue May 05 2020 19:45:48 GMT-0400 (EDT)
[debug] [2020-05-05T23:45:48.676Z] ----------------------------------------------------------------------
[debug] 
[debug] [2020-05-05T23:45:48.690Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2020-05-05T23:45:48.690Z] > authorizing via signed-in user
[debug] [2020-05-05T23:45:48.690Z] [iam] checking project cloud-functions-demo-5b1c8 for permissions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","cloudfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functions.update","cloudfunctions.operations.get","firebase.projects.get"]
[debug] [2020-05-05T23:45:48.693Z] >>> HTTP REQUEST POST https://cloudresourcemanager.googleapis.com/v1/projects/cloud-functions-demo-5b1c8:testIamPermissions  

[debug] [2020-05-05T23:45:48.887Z] <<< HTTP RESPONSE 200
[debug] [2020-05-05T23:45:50.700Z] TypeError: Cannot read property 'wanted' of undefined
    at /usr/local/lib/node_modules/firebase-tools/lib/checkFirebaseSDKVersion.js:37:51
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:229:7)
[error] 
[error] Error: An unexpected error has occurred.

I would appreciate any help in this area! I have already tried deleting the functions directory and just running firebase deploy but that has been unsuccessful. I have also tried downgrading node.js and npm to 6.9.2 (using n) but that hasn't worked either. Any help would be greatly appreciated!

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
jeff-ridgeway
  • 171
  • 16

2 Answers2

0

You should bump your cli version from 6.3.0 to 7.1.0 or above, as it fixes the issue reported here https://github.com/firebase/firebase-tools/issues/1469

Maybe also double check that your cloud functions package is up to date? It's hard to tell from your question what your current version is.

dmchk
  • 608
  • 6
  • 8
  • Ok, so I did ```npm install -g firebase-tools@7.1.0```, but I still got the same error that is above with the .log file. How do I check the cloud functions package to see if it's up to date? My firebase version with ```firebase --version``` is 6.3.0 – jeff-ridgeway May 06 '20 at 21:38
  • Hmm, sounds like it didn't update if the --version is still 6.3.0. Can you try running `npm install -g firebase-tools@latest`. The version should be 8.2.0 (the latest as of today) when you type in `firebase --version`. – dmchk May 06 '20 at 22:30
  • Yeah something is going on with my local computer? I run ```npm install -g firebase-tools@latest``` but when when I run ```firebase --version``` I still get 6.30 afterwards. I don't know why. I do get a warning saying ```deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142``` but I don't know what this means. – jeff-ridgeway May 07 '20 at 01:12
  • My guess is you may have additionally installed it not using npm, so it's pulling from a different place in your $PATH. You can run `which firebase` to find out. If you're not too familiar with what you're doing, I suggest uninstalling the npm package, making sure `firebase` is no longer installed anywhere else (and remove it if it it is), and then reinstalling the npm package. I think this is the root of your problem - good luck! – dmchk May 07 '20 at 02:26
  • I figured it out! I had to follow the steps [here](https://stackoverflow.com/questions/12607155/error-the-brew-link-step-did-not-complete-successfully) and [finally here](https://github.com/firebase/firebase-tools/issues/113) in that order. Thanks for the help! – jeff-ridgeway May 09 '20 at 22:27
0

So, I went down the rabbit hole online for a few days and finally found a solution through a combination of stackoverflow and GitHub.

First, do the instructions outlined here

Then, lastly do this in your terminal: alias firebase="`npm config get prefix`/bin/firebase" which was from this closed GitHub issue

Hope it helps someone!

jeff-ridgeway
  • 171
  • 16
  • From my own research, it seems information on cloud functions is patch work. The tutorials in docs in various places rarely work without some hair pulling. Is there a reliable source that actually explains cloud functions, showing how they work in detail? – user3951320 Jun 15 '20 at 11:30