Repository: next.js
Issue: Nextjs Vercel Deployment issue if I use a path to an existing, large folder in a string without file access.
Labels: bug

Hi all, I would like to bring this to your attention again. It is still not resolved. I updated the [Vercel bug report discussion](https://github.com/orgs/vercel/discussions/6719) with additional information.

### Link to the code that reproduces this issue

https://github.com/don-esteban/vercel-deployment-bug-reproduction

### To Reproduce

Deploy the project on Vercel. The deployment fails with an completely unrelated error message. Local production build are fine, as expected. I cross-posted this issue in a [Vercel discussion](https://github.com/orgs/vercel/discussions/6719).

It's really only this page component in the project. No file access only strings. The folder contains 2.000 files. Using a smaller subfolder does not cause issues. But again. Who cares? I do not access the file system at all.

```
import path from "path";

export default async function Page() {
  const base = path.join(process.cwd(), "contentsx4", "hersteller");
  return (
    <div>
      <h1>TEST</h1>
      <p>Base path: {base}</p>
    </div>
  );
}

```
This is the complete Error log:

```
[12:15:16.365] Running build in Washington, D.C., USA (East) – iad1
[12:15:16.583] Cloning github.com/don-esteban/vercel-deployment-bug-reproduction (Branch: main, Commit: c661e5d)
[12:15:17.049] Previous build cache not available
[12:15:29.260] Cloning completed: 12.675s
[12:15:31.226] Running "vercel build"
[12:15:32.176] Vercel CLI 34.1.7
[12:15:32.752] Installing dependencies...
[12:15:46.634] 
[12:15:46.635] added 453 packages in 14s
[12:15:46.635] 
[12:15:46.636] 149 packages are looking for funding
[12:15:46.636]   run `npm fund` for details
[12:15:46.662] Detected Next.js version: 14.2.3
[12:15:46.667] Detected `package-lock.json` generated by npm 7+
[12:15:46.668] Running "npm run build"
[12:15:46.917] 
[12:15:46.919] > sx5a@0.1.0 build
[12:15:46.919] > next build
[12:15:46.919] 
[12:15:48.577] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[12:15:48.577] This information is used to shape Next.js' roadmap and prioritize features.
[12:15:48.578] You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
[12:15:48.578] https://nextjs.org/telemetry
[12:15:48.578] 
[12:15:48.641]   ▲ Next.js 14.2.3
[12:15:48.643] 
[12:15:48.711]    Creating an optimized production build ...
[12:15:58.929]  ✓ Compiled successfully
[12:15:58.931]    Linting and checking validity of types ...
[12:16:02.574]    Collecting page data ...
[12:16:03.629]    Generating static pages (0/4) ...
[12:16:03.946]    Generating static pages (1/4) 
[12:16:03.955]    Generating static pages (2/4) 
[12:16:04.005]    Generating static pages (3/4) 
[12:16:04.098]  ✓ Generating static pages (4/4)
[12:16:04.238]    Finalizing page optimization ...
[12:16:04.238]    Collecting build traces ...
[12:16:09.579] 
[12:16:09.589] Route (app)                              Size     First Load JS
[12:16:09.589] ┌ ○ /                                    141 B          87.1 kB
[12:16:09.590] └ ○ /_not-found                          871 B          87.8 kB
[12:16:09.591] + First Load JS shared by all            87 kB
[12:16:09.591]   ├ chunks/23-54a5d170dbd3716c.js        31.5 kB
[12:16:09.591]   ├ chunks/fd9d1056-2821b0f0cabcd8bd.js  53.6 kB
[12:16:09.591]   └ other shared chunks (total)          1.84 kB
[12:16:09.591] 
[12:16:09.591] 
[12:16:09.591] ○  (Static)  prerendered as static content
[12:16:09.592] 
[12:16:09.669] Traced Next.js server files in: 32.222ms
[12:16:12.732] Warning: Max serverless function size of 250 MB uncompressed reached
[12:16:12.733] Serverless Function's page: index.js
[12:16:12.737] Large Dependencies                         Uncompressed size
[12:16:12.737] contentsx4/hersteller/citrix                        54.46 MB
[12:16:12.737] contentsx4/hersteller/mindmanager-mindjet           17.79 MB
[12:16:12.738] contentsx4/hersteller/sonicwall                     17.13 MB
[12:16:12.738] contentsx4/hersteller/parallels                     13.52 MB
[12:16:12.745] contentsx4/hersteller/macrium                       13.38 MB
[12:16:12.746] contentsx4/hersteller/devolutions                   12.06 MB
[12:16:12.746] contentsx4/hersteller/veeam                         11.47 MB
[12:16:12.746] contentsx4/hersteller/microsoft                       9.5 MB
[12:16:12.746] contentsx4/hersteller/nutanix                        9.22 MB
[12:16:12.746] contentsx4/hersteller/sophos                         9.19 MB
[12:16:12.746] contentsx4/hersteller/eset                           7.43 MB
[12:16:12.747] contentsx4/hersteller/watchguard                     7.33 MB
[12:16:12.747] contentsx4/hersteller/symantec                       6.13 MB
[12:16:12.747] contentsx4/hersteller/altova                         5.62 MB
[12:16:12.747] contentsx4/hersteller/veritas                        5.43 MB
[12:16:12.748] contentsx4/hersteller/datacore                       5.32 MB
[12:16:12.748] contentsx4/hersteller/vmware                         4.84 MB
[12:16:12.750] contentsx4/hersteller/google                         4.41 MB
[12:16:12.750] contentsx4/hersteller/abbyy                          4.36 MB
[12:16:12.750] contentsx4/hersteller/solarwinds                     4.24 MB
[12:16:12.751] contentsx4/hersteller/acronis                         4.2 MB
[12:16:12.751] contentsx4/hersteller/mcafee                         4.02 MB
[12:16:12.751] contentsx4/hersteller/techsmith                       3.7 MB
[12:16:12.751] contentsx4/hersteller/bitdefender                     3.1 MB
[12:16:12.752] contentsx4/hersteller/altaro                         2.29 MB
[12:16:12.752] contentsx4/hersteller/corel                             2 MB
[12:16:12.752] contentsx4/hersteller/gfi-software                   1.73 MB
[12:16:12.752] contentsx4/hersteller/flexera                        1.72 MB
[12:16:12.752] contentsx4/hersteller/malwarebytes                   1.61 MB
[12:16:12.753] contentsx4/hersteller/wasabi                         1.56 MB
[12:16:12.754] contentsx4/hersteller/arcserve                       1.27 MB
[12:16:12.754] node_modules/next/dist                                1.1 MB
[12:16:12.754] contentsx4/hersteller/mailstore                      1.02 MB
[12:16:12.754] contentsx4/hersteller/nuance                       926.74 KB
[12:16:12.754] contentsx4/hersteller/stormagic                     897.7 KB
[12:16:12.755] contentsx4/hersteller/trendmicro                   873.94 KB
[12:16:12.755] contentsx4/hersteller/red-hat                      854.53 KB
[12:16:12.755] contentsx4/hersteller/ibm                             797 KB
[12:16:12.755] contentsx4/hersteller/barracuda-networks           685.28 KB
[12:16:12.755] contentsx4/hersteller/progress                     672.56 KB
[12:16:12.756] contentsx4/hersteller/quest                         660.8 KB
[12:16:12.760] contentsx4/hersteller/n-able                       597.05 KB
[12:16:12.760] node_modules/react-dom/cjs                         545.26 KB
[12:16:12.760] 
[12:16:12.760] All dependencies                                   261.74 MB
[12:16:12.760] Max serverless function size was exceeded for 1 function
[12:16:12.782] Created all serverless functions in: 3.112s
[12:16:12.790] Collected static files (public/, static/, .next/static): 4.253ms
[12:16:12.817] Build Completed in /vercel/output [40s]
[12:16:13.032] Deploying outputs...
[12:16:32.635] Error: A Serverless Function has exceeded the unzipped maximum size of 250 MB. : https://vercel.link/serverless-function-size
[12:16:34.859] 
```

### Current vs. Expected behavior

It should deploy without issues.

### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:11:05 PDT 2024; root:xnu-10063.101.17~1/RELEASE_X86_64
  Available memory (MB): 32768
  Available CPU cores: 16
Binaries:
  Node: 20.9.0
  npm: 10.1.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.2.3 // Latest available version is detected (14.2.3).
  eslint-config-next: 14.2.3
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Not sure

### Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

### Additional context

_No response_