I'm doing Create Rollout in firebase app hosting with nextjs. It's failing because of a supposed error in firebase functions.
Type error: Cannot find module 'firebase-functions/v2/scheduler' or its corresponding type declarations.
I already successfully deployed this function via the cli firebase deploy
, and it can successfully run there in firebase. My package.json file in the functions folder has "firebase-functions": "^6.1.0"
which supports v2. It was my understanding that firebase app hosting is totally separate from functions also, and wouldn't be trying to deploy them. Why am I getting this error?
EDIT:
I made a new repo to confirm and reproduce the example, which can be seen here. This repo is just the results of create-next-app@latest . --ts
with all defaults followed by firebase init
. I created a new firebase project, deployed functions successfully via cli (v13.22.1). Doing a rollout in App Hosting gives the expected error:
Failed to compile.
./functions/src/index.ts:10:25 Type error: Cannot find module 'firebase-functions/v2/https' or its corresponding type declarations.
10 | import {onRequest} from "firebase-functions/v2/https";
The successfully deployed function: https://helloworld-dad3o2jpca-uc.a.run.app
The failed app: https://firebase-error-demo--fir-error-demo.us-central1.hosted.app/
I added firebase-functions as a dependency to my project (ie. the project level package.json, it was already in the functions package.json). I don't understand why this was necessary though as the function was already deployed and working.