0

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/

9
  • why are people voting to close? can someone give some feedback please, what is the problem?
    – esafresa
    Commented Apr 12 at 14:57
  • The problem is that you didn't show any code or state the specific steps to take to reproduce the issue. This is called a complete minimal reproduce example. You might have done something wrong, but no one could see what that was. It sounds like you might have just not run npm install, since the dependency was already in your project. The error you showed isn't clearly "in" firebase-functions at all, but rather something you were doing that left your tooling unable to use what you expected to be in place. Commented Apr 14 at 18:08
  • Thanks for the reply @DougStevenson. I'd like to push back on what you said if that's okay? In my mind, if a firebase function can be successfully deployed and then run, I feel my code and tooling is already shown to be correct. With zero changes to anything, I then do an App Hosting rollout and I get an error from the already deployed and working firebase function. I felt it might be a bug, because my understanding is App Hosting shouldn't be deploying firebase functions in the first place?
    – esafresa
    Commented Apr 15 at 4:16
  • Maybe I'm wrong on that, I couldn't find it documented anywhere so I just assumed it was akin to the og Firebase Hosting in that they deployed separately. But either way, why would it succeed via CLI firebase deploy and fail via app hosting Rollout...
    – esafresa
    Commented Apr 15 at 4:25
  • 1
    This question is similar to: Issues with Dependencies in Firebase App Hosting and Cloud Functions Deployments for Next.js App. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.
    – aldel
    Commented Apr 15 at 21:06

1 Answer 1

0

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.

1
  • 1
    I think when the deploy process runs Typescript at the top level, it doesn't know that it shouldn't include the functions directory. A better solution is to add "./functions" to the "exclude" section in tsconfig.json. See this answer: stackoverflow.com/a/79147010/2501624
    – aldel
    Commented Apr 15 at 21:03

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.