GCP functions-framework "function target ... is not defined" in CI
The Functions Framework loaded your module successfully, but the name you passed with --target is not exported from it. The source is fine; the target name is wrong or the export is misnamed.
What this error means
functions-framework fails with "Function 'helloWorld' is not defined in the provided module." even though the module imported without error.
gcp
Error: Function 'helloWorld' is not defined in the provided module.
Did you specify the correct target function to execute?Common causes
The --target name does not match any export
You passed --target=helloWorld but the module exports main (or a differently cased name), so no matching function is found.
The function is defined but not exported
The handler exists in the file but is not attached to exports/module.exports, so the framework cannot see it.
How to fix it
Match --target to the exported name
- List the module exports.
- Set
--targetto an exported function name exactly. - Re-run the framework.
Terminal
# exports.helloWorld = ...
npx functions-framework --target=helloWorldExport the handler
Attach the function to exports so the framework can resolve the target.
index.js
exports.helloWorld = (req, res) => res.send('ok');How to prevent it
- Keep --target identical to the exported function name.
- Export handlers explicitly from the source module.
- Verify the target in CI before deploying the function.
Related guides
GCP functions-framework "Could not load the function" in CIFix GCP Functions Framework "Provided module could not be loaded" / "Could not load the function" in CI - the…
AWS Lambda "Runtime.HandlerNotFound" in CIFix AWS Lambda "Runtime.HandlerNotFound: X is undefined or not exported" when invoking in CI - the module loa…
serverless-offline "Could not find handler" in CIFix serverless-offline "Failed to load resource: ... Could not find handler" / "Unable to determine handler"…