Closed Crash-GHaun closed 2 years ago
Hey @Crash-GHaun,
Thanks for the issue. Debugging this, I found that having the FF in both deps and devDeps causes errors in Cloud Build when building the function.
You don't need @google-cloud/functions-framework
in both. Just one or the other. GCF adds it if you don't have an explicit dep, so I would add it there. If you install via npm
, you cannot produce a package.json
like that (at least normally).
This worked for me:
{
"type": "module",
"name": "test_bot",
"version": "0.1.0",
"description": "Test Bot",
"scripts": {
"start": "npx functions-framework --target=test_bot"
},
"dependencies": {
"@google-cloud/functions-framework": "^3.0.0",
"@google-cloud/secret-manager": "^3.10.1"
}
}
gcloud functions deploy functions_test --trigger-http --runtime nodejs16 --entry-point=test_bot
Maybe @matthewrobertson knows what Buildpacks currently does to attempt to resolve this, if this is a bug, and maybe how we could resolve interesting error / edge case.
Can confirm this solved my problem! Thank you!
You're welcome. Have a good one :)
Closing this issue, as this is a misconfig / unsupported use of npm package.json
.
Docs: https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file
wow... that was a bizzare issue... solved it for cloudfunction v2
Hey Functions Framework Team!
I was attempting to deploy an Node JS (ESM) function to Cloud Functions when I hit a bit of a bug. When the function deploys on GCF I see the following error in the logs:
/bin/bash: node_modules/.bin/functions-framework: No such file or directory
When running the function locally all works as intended.
Package.json:
index.js:
To deploy:
gcloud beta functions deploy functions_test --region=europe-west1 --trigger-http --runtime=nodejs16
Things work locally when you run
npm start
but fails when it's on GCF. Adding --entry-point to the deployment makes no difference.Do we need a different start script for GCF?