Short answer
Set VERCEL_ANALYZE_BUILD_OUTPUT=1 and redeploy to see each function’s size. Remove duplicates with npm dedupe, move images, videos and big JSON files to public or to storage, and keep large files out with outputFileTracingExcludes in next.config.js (or excludeFiles in vercel.json outside Next.js). If the function really needs the size and your project is eligible, Vercel’s large functions (beta) allow up to 5 GB.
Why the function is too big, and the fix
01
One function bundle is over 250 MB uncompressed
“the maximum uncompressed size is 250 MB including layers which are automatically used depending on runtimes.” Vercel, Vercel Functions Limits
The limit counts everything the function ships with, uncompressed: your code, node_modules it uses and any file it reads. The error does not say which file is the problem, so measure first.
02
Measure which function and which files
“VERCEL_ANALYZE_BUILD_OUTPUT environment variable with the value 1 and redeploy. The build logs then list each function's uncompressed size” Vercel, Vercel Functions Limits
Add the environment variable VERCEL_ANALYZE_BUILD_OUTPUT with the value 1 in the project settings and redeploy. The build log then lists each function with its size and the largest files in it, so you know which package or folder to cut.
03
Heavy or duplicate packages
“Duplicate copies of the same package also add size. Run npm ls <package> to see why a package is installed, and npm dedupe to remove duplicates.” Vercel, Vercel Functions Limits
Some packages carry large binaries, such as headless browsers, image libraries or AI SDKs with native parts. Two versions of the same package double the cost. Run npm ls on the big ones to see who pulls them in, dedupe, and replace a heavy package with a lighter one or a hosted API where you can.
04
Files traced into the function by accident
“Images, videos, or large JSON files that server code imports or reads are packaged with the function.” Vercel, Vercel Functions Limits
An import or fs read with a path built at runtime can pull a whole folder into the bundle. Serve images, videos and large JSON from public or from storage, use fixed import paths, and exclude what the function never needs. In Next.js, list those paths under outputFileTracingExcludes in next.config.js.
// next.config.js (Next.js 15 and later; on 14 it sits under experimental) // only exclude files the function never reads at runtime module.exports = { outputFileTracingExcludes: { '/api/*': ['./public/**/*', './data/large/**/*'], }, };
Checked against the vendor’s docs on : Vercel: Functions limits (bundle size, troubleshooting the 250 MB limit, large functions).
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
Related: Vercel 413 payload too large · Vercel npm run build exited with 1 · Vercel function timeout 504 · Next.js Server Action body limit