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
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:
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.
Since the default entry point changed from v1 to v2 and there’s no gen2 versions of
onCreate()
andonDelete()
you’ll have to change your import to now explicity pull in v1 foronCreate()
i.e. changeimport * as functions from 'firebase-functions'
toimport * as functions from 'firebase-functions/v1'
.See https://github.com/firebase/firebase-functions/issues/1383 for more details.