Troubleshooting a `module not found` error on Vercel build logs for a Next.js project

41 replies
Last updated: May 28, 2022
hi all, im building a nextjs project. my problem is with vercel. im getting a
module not found - can't resolve
error on vercel’s build logs. build is successful locally but not on vercel. i tried to rename the file, change its order in the schema, deleted and reinstalled node_modules and non worked. i double checked the file ans it’s exported properly like other documents. it’s weird that it’s only this file
siteSettings
and i have no idea why. any ideas would be much appreciated
AI Update

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 siteSettings but the actual file is named SiteSettings.js (or vice versa), it works locally but fails on Vercel

How to Fix It:

  1. 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'
  2. Check the actual filename - Verify the exact casing of your file in your file explorer or with ls in terminal. Don't trust your IDE's display.

  3. Check the folder path casing too - The same case-sensitivity applies to folder names in the import path.

  4. 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 sitesettings to 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.

This looks like a path issue. Without seeing the error or the code, not much we can debug unfortunately.
Also just for clarification, are you deploy your frontend on Vercel or the Sanity studio?
user P
check also the Node version of the project in Vercel. It should match your local version
Here is an example
Frontend isn't deployed yet but it will be on vercel as well
Node version might be it. Let me check
How do you deploy your studio on Vercel? What does it look like?
When i disable that sitesettings import, the deploy is successfully on vercel
What does the import look like?
The problem is with that light of code
What the problematic one?
Yes?
Let me add a screenshot
I suspect a casing issue.
i checked casing
it looks ok
Can you take a screenshot of your file structure as well?
[16:09:24.268] Cloning <http://github.com/oalbacha/therapy-place-studio|github.com/oalbacha/therapy-place-studio> (Branch: main, Commit: 979983d)
[16:09:25.383] Cloning completed: 1.115s
[16:09:25.655] Installing build runtime...
[16:09:27.858] Build runtime installed: 2.203s
[16:09:28.136] Looking up build cache...
[16:09:31.546] Build cache downloaded [29.63 MB]: 3148.531ms
[16:09:31.775] Installing dependencies...
[16:09:35.673] 
[16:09:35.673] changed 1 package in 4s
[16:09:35.673] 
[16:09:35.674] 99 packages are looking for funding
[16:09:35.674]   run `npm fund` for details
[16:09:35.960] Detected `package-lock.json` generated by npm 7...
[16:09:35.960] Running "npm run build"
[16:09:36.328] 
[16:09:36.329] > therapyplacestudio@1.0.0 build
[16:09:36.329] > sanity build public -y
[16:09:36.329] 
[16:09:38.088] 
[16:09:38.088] Including the following environment variables as part of the JavaScript bundle:
[16:09:38.089] - SANITY_STUDIO_VERCEL_ARTIFACTS_OWNER
[16:09:38.089] - SANITY_STUDIO_VERCEL_ORG_ID
[16:09:38.089] - SANITY_STUDIO_VERCEL_GIT_COMMIT_REF
[16:09:38.090] - SANITY_STUDIO_VERCEL_GIT_REPO_SLUG
[16:09:38.090] - SANITY_STUDIO_VERCEL_GIT_PROVIDER
[16:09:38.090] - SANITY_STUDIO_VERCEL_PROJECT_ID
[16:09:38.090] - SANITY_STUDIO_VERCEL_GIT_REPO_OWNER
[16:09:38.090] - SANITY_STUDIO_VERCEL_GIT_COMMIT_MESSAGE
[16:09:38.090] - SANITY_STUDIO_VERCEL_GIT_REPO_ID
[16:09:38.091] - SANITY_STUDIO_VERCEL_URL
[16:09:38.091] - SANITY_STUDIO_VERCEL_ARTIFACTS_TOKEN
[16:09:38.091] - SANITY_STUDIO_VERCEL_ENV
[16:09:38.092] - SANITY_STUDIO_VERCEL_GIT_COMMIT_SHA
[16:09:38.092] - SANITY_STUDIO_VERCEL_GIT_COMMIT_AUTHOR_NAME
[16:09:38.092] - SANITY_STUDIO_VERCEL_BUILD_OUTPUTS_EDGE_FUNCTION
[16:09:38.092] - SANITY_STUDIO_VERCEL_GIT_COMMIT_AUTHOR_LOGIN
[16:09:38.092] - SANITY_STUDIO_VERCEL_API_DC_ENDPOINT
[16:09:38.092] 
[16:09:38.235] - Clearing output folder
[16:09:38.244] ✔ Clearing output folder (12ms)
[16:09:38.245] - Building Sanity
[16:09:58.269] ✖ Building Sanity
[16:09:58.271] 
[16:09:58.271] Error: Errors while building:
[16:09:58.271] ./schemas/schema.js?sanityPart=part%3A%40sanity%2Fbase%2Fschema
[16:09:58.271] Module not found: Error: Can't resolve './documents/siteSettings' in '/vercel/path0/schemas'
[16:09:58.271] resolve './documents/siteSettings' in '/vercel/path0/schemas'
[16:09:58.272]   using description file: /vercel/path0/package.json (relative path: ./schemas)
[16:09:58.272]     Field 'browser' doesn't contain a valid alias configuration
[16:09:58.272]   after using description file: /vercel/path0/package.json (relative path: ./schemas)
[16:09:58.273]     using description file: /vercel/path0/package.json (relative path: ./schemas/documents/siteSettings)
[16:09:58.273]       no extension
[16:09:58.273]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.273]         /vercel/path0/schemas/documents/siteSettings doesn't exist
[16:09:58.273]       .js
[16:09:58.273]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.274]         /vercel/path0/schemas/documents/siteSettings.js doesn't exist
[16:09:58.274]       .jsx
[16:09:58.274]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.274]         /vercel/path0/schemas/documents/siteSettings.jsx doesn't exist
[16:09:58.274]       .es6
[16:09:58.274]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.275]         /vercel/path0/schemas/documents/siteSettings.es6 doesn't exist
[16:09:58.275]       .es
[16:09:58.275]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.275]         /vercel/path0/schemas/documents/siteSettings.es doesn't exist
[16:09:58.275]       .mjs
[16:09:58.275]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.275]         /vercel/path0/schemas/documents/siteSettings.mjs doesn't exist
[16:09:58.275]       .ts
[16:09:58.276]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.276]         /vercel/path0/schemas/documents/siteSettings.ts doesn't exist
[16:09:58.276]       .tsx
[16:09:58.276]         Field 'browser' doesn't contain a valid alias configuration
[16:09:58.276]         /vercel/path0/schemas/documents/siteSettings.tsx doesn't exist
[16:09:58.276]       as directory
[16:09:58.276]         /vercel/path0/schemas/documents/siteSettings doesn't exist
[16:09:58.276] [/vercel/path0/schemas/documents/siteSettings]
[16:09:58.277] [/vercel/path0/schemas/documents/siteSettings.js]
[16:09:58.277] [/vercel/path0/schemas/documents/siteSettings.jsx]
[16:09:58.278] [/vercel/path0/schemas/documents/siteSettings.es6]
[16:09:58.278] [/vercel/path0/schemas/documents/siteSettings.es]
[16:09:58.278] [/vercel/path0/schemas/documents/siteSettings.mjs]
[16:09:58.278] [/vercel/path0/schemas/documents/siteSettings.ts]
[16:09:58.278] [/vercel/path0/schemas/documents/siteSettings.tsx]
[16:09:58.278] [/vercel/path0/schemas/documents/siteSettings]
[16:09:58.278]  @ ./schemas/schema.js?sanityPart=part%3A%40sanity%2Fbase%2Fschema 30:43-78
[16:09:58.278]  @ ./node_modules/@sanity/structure/lib/parts/Schema.js
[16:09:58.279]  @ ./node_modules/@sanity/structure/lib/InitialValueTemplateItem.js
[16:09:58.279]  @ ./node_modules/@sanity/structure/lib/index.js
[16:09:58.279]  @ ./node_modules/@sanity/desk-tool/lib/components/StructureError.js
[16:09:58.279]  @ ./node_modules/@sanity/desk-tool/lib/_parts/base-tool.js
[16:09:58.279]  @ ./node_modules/@sanity/desk-tool/lib/_parts/base-tool.js?sanityPart=all%3Apart%3A%40sanity%2Fbase%2Ftool
[16:09:58.279]  @ ./node_modules/@sanity/default-layout/lib/util/getRegisteredTools.js
[16:09:58.280]  @ ./node_modules/@sanity/default-layout/lib/router.js
[16:09:58.280]  @ ./node_modules/@sanity/default-layout/lib/Root.js?sanityPart=part%3A%40sanity%2Fbase%2Froot
[16:09:58.280]  @ ./node_modules/@sanity/base/lib/components/SanityRoot.js?sanityPart=part%3A%40sanity%2Fbase%2Fsanity-root
[16:09:58.281]  @ ./node_modules/@sanity/server/lib/browser/entry.js
[16:09:58.281]  @ multi ./node_modules/@sanity/server/lib/browser/entry.js
[16:09:58.282]     at buildStaticAssets (~/path0/node_modules/@sanity/core/lib/actions/build/buildStaticAssets.js:131:13)
[16:09:58.328] Error: Command "npm run build" exited with 1
export default {
  title: 'Business Details',
  name: 'siteSettings',
  type: 'document',
  __experimental_actions: [/*'create',*/ 'update', /*'delete',*/ 'publish'],
  fields: [
    {
      title: 'Legal Business Name',
      name: 'name',
      type: 'string'
    },
    {
      title: 'Logo',
      name: 'logo',
      type: 'image'
    },
    {
      title: 'Address'
      description: 'Maybe city, state and country?',
      name: 'address',
      type: 'string'
    },
    {
      title: 'Email',
      name: 'email',
      type: 'email'
    },
    {
      title: 'Phone',
      name: 'phone',
      type: 'string'
    },
    {
      title: 'Terms & Conditions',
      name: 'terms',
      type: 'blockContent'
    },
    {
      title: 'Privacy Policy',
      name: 'privacy',
      type: 'blockContent'
    },
  ],
}
import siteSettings from './documents/siteSettings'
No, it’s a path issue so I want to see what your folders look like. You can take a screenshot of the tree view in your IDE.
its in documents under schemas
Can you please show it…? 😅
And that faulty line is in in
./schemas/schema.js
, right?
yes
Out of sheer curiosity, can you try renaming the file + your import and deploy again?
Yep lets try that
i think this is working
Odd. I still think it looks like a casing issue.
it worked
but hows it a casing issue if all the cases are matching?
Can you try to rename it to
siteSettings
again and give it one more shot? Don’t undo your last commit. Just do a new one properly.
haha
ok one sec
siteSettings worked now
you are a STAR
thank youuu!!!
i might have misspelled it
Here is what I think happened: you might have created
sitesettings.js
(or any casing variation) and committed that. Then, noticing the casing mistake, you’ve renamed the file on disk. Because of your
core.ignorecase
git setting, that was not picked up by git. So you had an inconsistency between the path on git, and the one locally.
Interesting, didnt know about that. Thanks a again 👍
TIL. Nice troubleshooting, Kitty.

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.

Was this answer helpful?