Skip to content

Vercel deploy errorVercel: “Serverless Function has exceeded the unzipped maximum size of 250 MB”

The deploy fails during the build with Serverless Function has exceeded the unzipped maximum size of 250 MB. One function bundle, with everything it imports and reads, is over Vercel’s limit. It usually comes from one heavy package, a duplicate, or files that get traced into the function by accident.

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

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Related: Vercel 413 payload too large · Vercel npm run build exited with 1 · Vercel function timeout 504 · Next.js Server Action body limit

Questions

More on this error

Can I just raise the limit?

Vercel’s large functions (beta) deploy bundles up to 5 GB on supported runtimes. They require fluid compute with Active CPU enabled. Trimming the bundle is still worth doing, because a smaller function usually starts faster.

Does the limit apply to Python?

Python functions get more room: Vercel’s limits page sets 500 MB uncompressed for Python. Large functions (beta) also support Python.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. 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.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.