Skip to content
Latchkey

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

  1. List the module exports.
  2. Set --target to an exported function name exactly.
  3. Re-run the framework.
Terminal
# exports.helloWorld = ...
npx functions-framework --target=helloWorld

Export 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →