skip to Main Content

I have a Firebase project which uses a mix of Cloud Functions 1st Gen and Cloud Functions 2st Gen.

I recently updated both the Firebase CLI and SDK with the following commands

npm install firebase-functions@latest firebase-admin@latest --save

as advised in the Cloud Functions documentation and now I get the following error when deploying:

TypeError: functions.region is not a function

How to solve this problem?

2

Answers


  1. Chosen as BEST ANSWER

    The problem most probably comes from the fact that you updated the firebase-functions package from a v5.x.x version to a v6.x.x version.

    As mentioned in the releases notes, v6.0.0 introduces the following breaking change and this is the cause of your error:

    Breaking: Change default entrypoint of the firebase-functions package to v2 instead of v1

    The best solution is to do as described in the release notes, i.e. change the default entry point of the firebase-functions package to v2.

    Another solution is to revert back to the last v5 version, i.e. v5.1.1.


  2. Since the default entry point changed from v1 to v2 and there’s no gen2 versions of onCreate() and onDelete() you’ll have to change your import to now explicity pull in v1 for onCreate() i.e. change import * as functions from 'firebase-functions' to import * as functions from 'firebase-functions/v1'.

    See https://github.com/firebase/firebase-functions/issues/1383 for more details.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search