Serverless Function has exceeded the unzipped maximum size of 250 MB
On this page
Short answer
One of your functions is bigger than Vercel's 250 MB limit once it's unpacked. Turn on the bundle report to see which files are in it, then exclude the ones it doesn't need. Use excludeFiles in vercel.json, or outputFileTracingExcludes for Next.js. If the function really needs the space, check whether your project can use large functions.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.
The exact error you'll see
The build fails with this line. Vercel quotes it in the Functions skill it publishes in its vercel-plugin repo:
Serverless Function has exceeded the unzipped maximum size of 250 MB
The limit applies to the uncompressed function bundle, not to your repo or source folder.
Applies to
- Vercel Functions on the standard limit: 250 MB uncompressed, or 500 MB for Python
- Next.js server routes and API routes, including apps built with v0 or Cursor
- Settings involved:
vercel.jsonfunctionsconfig,next.config.jstracing options, and project environment variables
Why it happens
- The limit counts more than your code. Vercel says the 250 MB maximum is "including layers which are automatically used depending on runtimes."
- Heavy dependencies. Vercel names packages that ship binaries, such as Puppeteer with its bundled Chromium, and machine learning libraries. "Duplicate copies of the same package also add size."
- Static assets traced into the function. "Images, videos, or large JSON files that server code imports or reads are packaged with the function."
- Imports with variable paths. A path built at runtime "can make the bundler include every file in a directory."
- Next.js tracing. During
next build, Next.js uses@vercel/nftto "statically analyzeimport,require, andfsusage to determine all files that a page might load."
How to fix it, step by step
- In Settings → Environment Variables, add
VERCEL_ANALYZE_BUILD_OUTPUTwith the value1and redeploy. Vercel says the build logs then "list each function's uncompressed size and its largest files." - Work down the largest files. Run
npm ls <package>to see why a package is installed andnpm dedupeto remove duplicates. Move images, videos and large JSON to thepublicdirectory or external storage, and use static import paths. - If you're not on Next.js, exclude files the function doesn't need in
vercel.json. This is Vercel's example. It keepspublicandtestout of every function underapi:
{
"functions": {
"api/**": {
"excludeFiles": "{public,test}/**"
}
}
}
- On Next.js,
includeFilesandexcludeFilesaren't supported. UseoutputFileTracingExcludesinnext.config.jsinstead. The keys are route globs and the values are glob patterns resolved from the project root. This is part of the Next.js example:
module.exports = {
outputFileTracingExcludes: {
'/api/*': ['src/temp/**/*', 'public/large-logs/**/*'],
},
}
Swap in the paths your report flagged. Next.js says to keep patterns "as narrow as possible to avoid oversized traces (avoid **/* at the repo root)."
- If the files are all needed, look at large functions (beta). They allow uncompressed bundles "up to 5 GB" on Node.js, Bun and Python, and they "require fluid compute with Active CPU enabled." New projects are eligible by default. Existing projects opt in with the
VERCEL_SUPPORT_LARGE_FUNCTIONSenvironment variable, then redeploy. - Redeploy and watch the build get past the size check.
What the docs don't spell out
- Excluding a file the function reads breaks it at run time, not at build time. Vercel's file guide explains how to include files a function reads while it runs. After trimming, test every route that reads files from disk. (Using files in functions (opens in a new tab))
- Next.js trace options only touch server traces. Fully static pages and Edge Runtime routes aren't affected, so excluding paths for them won't shrink anything. (Next.js output (opens in a new tab))
- The large-functions variable works both ways. Vercel's skill says it "always takes precedence over the project default, in both directions," and only functions over 250 MB use the large-function path. (Vercel Functions skill (opens in a new tab))
How to check it worked
- The new deployment builds without the 250 MB error.
- With
VERCEL_ANALYZE_BUILD_OUTPUT=1still set, the build log shows the function under the limit. - Routes that read templates, data files or binaries still work on the live deployment.
Sources
- https:/
/ : exact build error, large-functions variable precedencegithub. com/ vercel/ vercel- plugin/ blob/ main/ skills/ vercel- functions/ SKILL. md (opens in a new tab) - https:/
/ : 250 MB and 500 MB limits including layers, common causes,vercel. com/ docs/ functions/ limitations (opens in a new tab) VERCEL_ANALYZE_BUILD_OUTPUT,npm ls/npm dedupe,excludeFilesexample, large functions requirements and opt-in - https:/
/ :vercel. com/ docs/ project- configuration/ vercel- json (opens in a new tab) includeFiles/excludeFilesnot supported in Next.js - https:/
/ :nextjs. org/ docs/ app/ api- reference/ config/ next- config- js/ output (opens in a new tab) @vercel/nfttracing,outputFileTracingExcludesexample, narrow patterns, static and Edge routes unaffected - https:/
/ : including files a function reads at run timevercel. com/ kb/ guide/ how- can- i- use- files- in- serverless- functions (opens in a new tab)
Related fixes
Tool to consider: Vercel.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.