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 :'(
Below is the build with the errors at the bottom:
1[20:04:47.184] Running build in Washington, D.C., USA (East) – iad12[20:04:47.285] Cloning github.com/philip-john-withers/fondunt-current (Branch: main, Commit: 481d2b1)3[20:04:47.291] Skipping build cache, deployment was triggered without cache.4[20:05:20.777] Cloning completed: 33.492s5[20:05:32.369] Running "vercel build"6[20:05:32.928] Vercel CLI 41.1.47[20:05:33.457] Installing dependencies...8[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.9[20:05:41.062] npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead10[20:05:41.119] npm warn deprecated @humanwhocodes/config-array@0.13.0: Use @eslint/config-array instead11[20:05:42.937] npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported12[20:05:42.994] npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported13[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.14[20:06:02.063] 15[20:06:02.063] added 1310 packages in 28s16[20:06:02.063] 17[20:06:02.063] 252 packages are looking for funding18[20:06:02.063] run `npm fund` for details19[20:06:02.147] Detected Next.js version: 15.1.720[20:06:02.161] Running "npm run build"21[20:06:02.298] 22[20:06:02.298] > prebuild23[20:06:02.298] > npm run typegen24[20:06:02.298] 25[20:06:02.439] 26[20:06:02.439] > typegen27[20:06:02.439] > sanity typegen generate28[20:06:02.439] 29[20:06:03.043] [WARN] Running in production environment mode30[20:06:03.043] 31[20:06:03.807] - Generating types32[20:06:04.341] ✓ Generated TypeScript types for 31 schema types and 8 GROQ queries in 1 files into: ./sanity.types.ts33[20:06:04.360] 34[20:06:04.361] > build35[20:06:04.361] > next build36[20:06:04.361] 37[20:06:04.984] Attention: Next.js now collects completely anonymous telemetry regarding usage.38[20:06:04.984] This information is used to shape Next.js' roadmap and prioritize features.39[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:40[20:06:04.984] https://nextjs.org/telemetry41[20:06:04.985] 42[20:06:05.097] ▲ Next.js 15.1.743[20:06:05.097] 44[20:06:05.123] Creating an optimized production build ...45[20:06:25.341] ✓ Compiled successfully46[20:06:25.434] Linting and checking validity of types ...47[20:06:29.888] Collecting page data ...48[20:06:34.647] Generating static pages (0/11) ...49[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.]50[20:06:35.106] Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error51[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.52[20:06:35.106] at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:490)53[20:06:35.106] at Xc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:68:409)54[20:06:35.106] at Zc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:210)55[20:06:35.106] at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)56[20:06:35.106] at Zc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:70:481)57[20:06:35.106] at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:89)58[20:06:35.106] at $c (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:78:98)59[20:06:35.107] at bd (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:77:404)60[20:06:35.107] at Z (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:76:217)61[20:06:35.107] at Zc (/vercel/path0/node_modules/react-dom/cjs/react-dom-server.browser.production.min.js:71:479)62[20:06:35.107] Export encountered an error on /_error: /404, exiting the build.63[20:06:35.116] ⨯ Next.js build worker exited with code: 1 and signal: null64[20:06:35.184] npm error Lifecycle script `build` failed with error:65[20:06:35.184] npm error code 166[20:06:35.184] npm error path /vercel/path0/nextjs-app67[20:06:35.184] npm error workspace nextjs-app68[20:06:35.184] npm error location /vercel/path0/nextjs-app69[20:06:35.184] npm error command failed70[20:06:35.184] npm error command sh -c next build71[20:06:35.198] Error: Command "npm run build" exited with 172[20:06:35.871]