Module not found: Can't resolve '@sanity/client' and 'groq' on Vercel deploy
./pages/episodes/[slug].js11
:33:35.354Module not found: Can't resolve '@sanity/client' in '/vercel/path0/pages/episodes'
./pages/index.js11
:33:35.355Module not found: Can't resolve 'groq' in '/vercel/path0/pages'
./pages/index.js11
:33:35.355Module not found: Can't resolve '@sanity/client' in '/vercel/path0/pages'
Build failed because of webpack errors1135.392Error! Command "npm run build" exited with 11135.497Error: Command "vercel build" exited with 1
This is a classic dependency installation issue! The errors show that Webpack can't find the @sanity/client and groq packages during your Vercel build, which means they're not installed in your project.
Here's how to fix it:
1. Install the missing packages locally:
npm install @sanity/client groqor if you're using yarn:
yarn add @sanity/client groq2. Verify your package.json:
After installing, make sure these packages appear in your package.json under "dependencies" (not "devDependencies"). They should look something like:
{
"dependencies": {
"@sanity/client": "^6.x.x",
"groq": "^3.x.x"
}
}3. Commit and push:
git add package.json package-lock.json
git commit -m "Add missing Sanity dependencies"
git pushWhy this happens:
This typically occurs when:
- You installed these packages globally instead of locally in your project
- You copied code from a tutorial but didn't install all dependencies
- Your
node_modulesfolder exists locally (so it works on your machine) but the packages aren't listed inpackage.json, so Vercel doesn't know to install them
Note on versions:
If you're starting fresh, consider using the next-sanity package instead, which bundles the client and provides helpful Next.js-specific utilities. You can install it with:
npm install next-sanity @sanity/image-urlThis should resolve your Vercel deployment errors. The build will work once Vercel can properly install all your dependencies from package.json!
Show original thread1 reply
Was this answer helpful?
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.