functions-framework-nodejs: Deployment of function for TS failure
Hello,
I believe I’ve discovered a bug which I’ve been able to reproduce consistently I felt worth reporting.
Summary
When using Typescript to build and deploy a function, if the target dir/file is in the gitignore, then the deployment fails.
Description
Following on from #254, I found the issue as a similar error occurred to me:
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: dist/index.js does not exist; Error ID: 9e84f54e
As it turns out, when I have the file in my .gitignore, the command fails:
gcloud functions deploy notify-github --runtime nodejs14 --trigger-http --region australia-southeast1
However, removing dist/
from my .gitignore file and re-running the same command works fine.
Sample code from https://github.com/golergka/gcf-typescript-template can be copy/pasted to replicate.
Originally discovered with:
Google Cloud SDK 339.0.0
bq 2.0.67
core 2021.04.30
gsutil 4.61
I noticed my tooling was a bit out of date, so I have updated just to make sure, but it was to no effect:
Google Cloud SDK 346.0.0
bq 2.0.69
core 2021.06.18
gsutil 4.63
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 19 (7 by maintainers)
Thank you @alexjmoore this has solved the issue. In your link at the bottom of the post, there’s an example section, which is where I originally took some of the example code I think
Perhaps the docs here could be amended to make it abundantly clear what’s going on (for future readers).
Really appreciate the help, and you too @grant. Thanks 😃
I think I might understand what is happening here. In
.gcloudignore
file example you have the line at the end:Despite starting with a # this actually is a command to tell
.gcloudignore
to also pull in entries from.gitignore
and in there of course you are telling it to ignoredist/
which is why it never makes it up for deployment.So you could either remove that line or you could override the .gitignore elements you do want to be uploaded, you can do that for
dist/
with a!dist/
after the#!include
line, i.e. at the very end of he file, so the whole file will look like:For more information on this, you can read more on the ‘advanced topics’ section at the bottom of this page: https://cloud.google.com/sdk/gcloud/reference/topic/gcloudignore