We are experiencing persistent build failures on Vercel for our Next.js 15.2.3 project using Supabase. The builds fail consistently, even though the code builds and runs correctly locally using both npm run dev and npm run build.
The primary error occurs during the build process and seems to indicate file corruption specific to the Vercel environment. The build log consistently shows a TypeScript error originating from lib/supabase.ts, stating Type error: Cannot find name 'generateMetadata'. (or similar errors indicating extraneous text).
Example Error Snippet (from commit 5138b01 build log):
./lib/supabase.ts:18:3Type error: Cannot find name 'generateMetadata'.
[0m [90m 16 | [39m [36mif [39m ( [33m! [39msupabaseUrl [33m|| [39m [33m! [39msupabaseAnonKey) { [0m [0m [90m 17 | [39m [36mthrow [39m [36mnew [39m [33mError [39m( [32m'Missing Supabase environment variables' [39m) [33m; [39m [0m [0m [31m [1m> [22m [39m [90m 18 | [39m }[generateMetadata] and [ [33mIngredientPage [39m] [33mApr [39m [35m01 [39m [35m11 [39m [33m: [39m [35m48 [39m [33m: [39m [35m03.29 [39m [0m [0m [90m | [39m [31m [1m^ [22m [39m [0m [0m [90m 19 | [39m [36mexport [39m [36mconst [39m supabase [33m= [39m createClient(supabaseUrl [33m, [39m supabaseAnonKey) [33m; [39m [0m [0m [90m 20 | [39m [0m [0m [90m 21 | [39m [90m// Helper functions for common database operations [39m [0mThis shows extraneous text (seemingly from previous logs) being inserted into lib/supabase.ts at line 18 during the build, causing the syntax/type error.
Troubleshooting Steps Taken:
- Verified the code builds and runs correctly locally.
- Addressed potential Next.js 15 compatibility issues (Promise-based
params, removed deprecatedswcMinify). - Pushed multiple commits with fixes.
- Cleared Vercel Build Cache via Project Settings -> Git.
- Cleared Vercel Data Cache via Project Settings -> Data Cache.
- Triggered multiple redeploys without using the build cache.
- Attempted
git revertand re-applying fixes in new commits. - Restored the affected file (
lib/supabase.ts) locally usinggit checkoutmultiple times before committing/pushing.
Despite these steps, the file corruption error persists specifically within the Vercel build environment.
Is anyone else experiencing issues like this? Any recommended solutions? We're pretty close to just starting over.