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
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"
}