Vercel build error

I’m a complete amateur to this, but I managed to get a project up & running using this template on my local then after a huge amount of issues I pushed this to Vercel.

It was hunky dory until I added the Sanity media plugin.

Everything runs smoothly on my local, but it refuses to build in Vercel and hitting the same error, no matter what I try. Please help :cry:

Below is the build with the errors at the bottom:

[20:04:47.184] Running build in Washington, D.C., USA (East) – iad1
[20:04:47.285] Cloning github.com/philip-john-withers/fondunt-current (Branch: main, Commit: 481d2b1)
[20:04:47.291] Skipping build cache, deployment was triggered without cache.
[20:05:20.777] Cloning completed: 33.492s
[20:05:32.369] Running "vercel build"
[20:05:32.928] Vercel CLI 41.1.4
[20:05:33.457] Installing dependencies...
[20:05:38.625] npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
[20:05:41.062] npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
[20:05:41.119] npm warn deprecated @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead
[20:05:42.937] npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
[20:05:42.994] npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
[20:05:46.767] npm warn deprecated eslint@8.57.1: This version is no longer supported. Please see https://eslint.org/version-support for other options.
[20:06:02.063] 
[20:06:02.063] added 1310 packages in 28s
[20:06:02.063] 
[20:06:02.063] 252 packages are looking for funding
[20:06:02.063]   run `npm fund` for details
[20:06:02.147] Detected Next.js version: 15.1.7
[20:06:02.161] Running "npm run build"
[20:06:02.298] 
[20:06:02.298] > prebuild
[20:06:02.298] > npm run typegen
[20:06:02.298] 
[20:06:02.439] 
[20:06:02.439] > typegen
[20:06:02.439] > sanity typegen generate
[20:06:02.439] 
[20:06:03.043] [WARN] Running in production environment mode
[20:06:03.043] 
[20:06:03.807] - Generating types
[20:06:04.341] ✓ Generated TypeScript types for 31 schema types and 8 GROQ queries in 1 files into: ./sanity.types.ts
[20:06:04.360] 
[20:06:04.361] > build
[20:06:04.361] > next build
[20:06:04.361] 
[20:06:04.984] Attention: Next.js now collects completely anonymous telemetry regarding usage.
[20:06:04.984] This information is used to shape Next.js' roadmap and prioritize features.
[20:06:04.984] 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:
[20:06:04.984] https://nextjs.org/telemetry
[20:06:04.985] 
[20:06:05.097]    ▲ Next.js 15.1.7
[20:06:05.097] 
[20:06:05.123]    Creating an optimized production build ...
[20:06:25.341]  ✓ Compiled successfully
[20:06:25.434]    Linting and checking validity of types ...
[20:06:29.888]    Collecting page data ...
[20:06:34.647]    Generating static pages (0/11) ...
[20:06:35.106] [Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%24%24typeof%2C%20type%2C%20key%2C%20ref%2C%20props%7D for the full message or use the non-minified dev environment for full errors and additional helpful warnings.]
[20:06:35.106] Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
[20:06:35.106] Error: Minified React error #31; visit https://reactjs.org/docs/error-decoder.html?invariant=31&args[]=object%20with%20keys%20%7B%24%24typeof%2C%20type%2C%20key%2C%20ref%2C%20props%7D for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
[20:06:35.106]     at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:490)
[20:06:35.106]     at Xc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:409)
[20:06:35.106]     at Zc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:210)
[20:06:35.106]     at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
[20:06:35.106]     at Zc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:481)
[20:06:35.106]     at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)
[20:06:35.106]     at $c (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)
[20:06:35.107]     at bd (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)
[20:06:35.107]     at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)
[20:06:35.107]     at Zc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:71:479)
[20:06:35.107] Export encountered an error on /_error: /404, exiting the build.
[20:06:35.116]  ⨯ Next.js build worker exited with code: 1 and signal: null
[20:06:35.184] npm error Lifecycle script `build` failed with error:
[20:06:35.184] npm error code 1
[20:06:35.184] npm error path /vercel/path0/nextjs-app
[20:06:35.184] npm error workspace nextjs-app
[20:06:35.184] npm error location /vercel/path0/nextjs-app
[20:06:35.184] npm error command failed
[20:06:35.184] npm error command sh -c next build
[20:06:35.198] Error: Command "npm run build" exited with 1
[20:06:35.871]

There’s another community post with 404 debugging tips that might be helpful. Please give these solutions a try and let us know how it goes.

A human should be around soon to offer more advice. But you can also get helpful information quickly by asking v0.

Hey @philip-john-withers. Were you able to find a solution for the Minified React error #31 thrown in this build?