Cloud functions allow me to focus on getting the logic written and leaving the uptime to the pros.
There was just one little problem. Every time I created a new repo that included a build step – in my case building from typescript – my deployments to gcloud would fail. I could run them in the gcloud simulator. However, on deployment I would be greeted with the following, lovely, error message:
(gcloud.beta.functions.deploy) OperationError: code=3, message=Function load error: File lib/functions/index.js that is expected to define function doesn’t exist
After beating my head against this issue enough times, I’ve finally decided to move the solution from my faulty memory to the internet at large.
Here’s the one-line fix. Add the following to your
.gcloudignore file at the
root of the repo:
Understandably we add the build directory for the repo to the
It turns out that gcloud functions respects the
.gitignore when building your
project and doesn’t see the
/lib directory that has the code
expected to run for your function.
It’s such a small thing, but I hope this saves you from beating your head on your desk in the future just as I hope it saves me.