DEV Community

loading...

functions/lib/index.js does not exist, can't deploy Cloud Functions

wceolin profile image Will Ceolin ・1 min read

Sometimes when you're deploying a monorepo to Cloud Functions for Firebase, you'll get the following error:

Error: There was an error reading functions/package.json:
 functions/lib/index.js does not exist, can't deploy Cloud Functions
Enter fullscreen mode Exit fullscreen mode

In some cases, that's happening because you're importing external types and Typescript is adding them to the compiled lib folder. Therefore, Firebase isn't able to find your functions because the default path is wrong.

Because Firebase uses the main field from your functions/package.json file, you just have to update it with the correct compiled path:

{
  "main": "lib/functions/src/index.js"
}
Enter fullscreen mode Exit fullscreen mode

Discussion (3)

Collapse
help_me_iam_verking profile image
makinggainz

This did not work for me.

Collapse
help_me_iam_verking profile image
Collapse
dondozone profile image
DonDozone

Thanks for the information! It was driving me nuts why it didn't work anymore, after I did some very minor type changes :D

Forem Open with the Forem app