Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when deploying Cloud Functions for Firebase: TypeError: functions.region is not a function

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?

like image 833
Renaud Tarnec Avatar asked Sep 01 '25 20:09

Renaud Tarnec


1 Answers

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.

like image 114
Tom Avatar answered Sep 03 '25 13:09

Tom