Netlify Edge "Failed to load edge function" in CI
Netlify Edge Functions run on Deno. During the build Netlify bundles each function with the edge bundler; if a function throws at module load, imports something unavailable, or has a syntax error, the build reports it failed to load.
What this error means
The Netlify build fails with "Failed to load edge function <name>" or "Bundling of edge function failed", often with a Deno error or a stack trace from the function module.
Bundling edge functions...
Failed to load edge function "geolocate":
error: Uncaught SyntaxError: The requested module './util.ts' does not provide
an export named 'lookup'Common causes
A bad import or missing export in the function
The function imports a name that the target module does not export, or references a file path that does not exist, so Deno fails to evaluate the module.
Code that runs at module top level and throws
Initialization at the top of the function file throws during bundling, so the function never loads.
How to fix it
Run the edge bundler locally
- Reproduce with
netlify buildornetlify devto see the same load error. - Fix the missing export, wrong path, or top-level throw it reports.
- Confirm the function exports a default handler.
export default async (request, context) => {
return new Response('ok');
};Keep top-level code side-effect free
Move initialization into the handler so a slow or failing setup does not break module load.
How to prevent it
- Run netlify build locally before pushing edge function changes.
- Export a default handler and keep imports correct.
- Avoid throwing work at the top level of an edge function.