Troubleshooting a `module not found` error on Vercel build logs for a Next.js project
This is a common issue that usually comes down to case-sensitivity differences between your local environment and Vercel's build environment. Here's what's likely happening:
The Root Cause:
- Your local machine (especially on macOS or Windows) has a case-insensitive file system
- Vercel's build environment uses Linux, which has a case-sensitive file system
- If you're importing
siteSettingsbut the actual file is namedSiteSettings.js(or vice versa), it works locally but fails on Vercel
How to Fix It:
Check your import statement casing - Look at where you're importing the siteSettings schema file. The import path must match the actual filename exactly, including capitalization:
// If your file is siteSettings.js import siteSettings from './siteSettings' // NOT import siteSettings from './SiteSettings'Check the actual filename - Verify the exact casing of your file in your file explorer or with
lsin terminal. Don't trust your IDE's display.Check the folder path casing too - The same case-sensitivity applies to folder names in the import path.
Verify your schema index file - If you're exporting from an index file (like
schemas/index.js), make sure the import there also matches exactly:export {default as siteSettings} from './siteSettings'
Quick Debug Steps:
- Run
git ls-files | grep -i sitesettingsto see exactly how Git has tracked the filename - Check your
schemas/index.js(or wherever you're aggregating schemas) for the import statement - Look for any dynamic imports or require statements that might reference this file
Since you mentioned it works locally but not on Vercel, and you've already tried reinstalling dependencies, case-sensitivity is almost certainly the culprit. Even a single character difference in capitalization will cause this exact error pattern.
Sanity – Build the way you think, not the way your CMS thinks
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.