Unlock seamless workflows and faster delivery with our latest releases – get the details

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
May 28, 2022, 11:59 AM
This looks like a path issue. Without seeing the error or the code, not much we can debug unfortunately.
May 28, 2022, 12:11 PM
Also just for clarification, are you deploy your frontend on Vercel or the Sanity studio?
May 28, 2022, 12:11 PM
user P
check also the Node version of the project in Vercel. It should match your local version
May 28, 2022, 12:40 PM
Here is an example
May 28, 2022, 12:40 PM
Frontend isn't deployed yet but it will be on vercel as well
May 28, 2022, 1:54 PM
Node version might be it. Let me check
May 28, 2022, 1:55 PM
How do you deploy your studio on Vercel? What does it look like?
May 28, 2022, 1:55 PM
When i disable that sitesettings import, the deploy is successfully on vercel
May 28, 2022, 1:55 PM
What does the import look like?
May 28, 2022, 1:56 PM
The problem is with that light of code
May 28, 2022, 1:56 PM
What the problematic one?
May 28, 2022, 1:56 PM
Yes?
May 28, 2022, 1:56 PM
Let me add a screenshot
May 28, 2022, 1:56 PM
I suspect a casing issue.
May 28, 2022, 1:57 PM
i checked casing
May 28, 2022, 1:58 PM
it looks ok
May 28, 2022, 1:58 PM
Can you take a screenshot of your file structure as well?
May 28, 2022, 1:59 PM
[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
May 28, 2022, 1:59 PM
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'
    },
  ],
}
May 28, 2022, 2:01 PM
import siteSettings from './documents/siteSettings'
May 28, 2022, 2:01 PM
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.
May 28, 2022, 2:01 PM
its in documents under schemas
May 28, 2022, 2:03 PM
Can you please show it…? 😅
May 28, 2022, 2:04 PM
And that faulty line is in in
./schemas/schema.js
, right?
May 28, 2022, 2:05 PM
yes
May 28, 2022, 2:06 PM
Out of sheer curiosity, can you try renaming the file + your import and deploy again?
May 28, 2022, 2:06 PM
Yep lets try that
May 28, 2022, 2:07 PM
i think this is working
May 28, 2022, 2:16 PM
Odd. I still think it looks like a casing issue.
May 28, 2022, 2:16 PM
it worked
May 28, 2022, 2:17 PM
but hows it a casing issue if all the cases are matching?
May 28, 2022, 2:18 PM
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.
May 28, 2022, 2:18 PM
haha
May 28, 2022, 2:19 PM
ok one sec
May 28, 2022, 2:19 PM
siteSettings worked now
May 28, 2022, 2:21 PM
you are a STAR
May 28, 2022, 2:21 PM
thank youuu!!!
May 28, 2022, 2:21 PM
i might have misspelled it
May 28, 2022, 2:22 PM
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.
May 28, 2022, 2:23 PM
Interesting, didnt know about that. Thanks a again 👍
May 28, 2022, 2:59 PM
TIL. Nice troubleshooting, Kitty.
May 28, 2022, 5:52 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?