Build Failure Because of Webpack Errors

1 replies
Last updated: Jun 16, 2022
hey, beautiful people, I'm trying to deploy to vercel and I'm getting this series of errors
./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
AI Update

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 groq

or if you're using yarn:

yarn add @sanity/client groq

2. 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 push

Why 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_modules folder exists locally (so it works on your machine) but the packages aren't listed in package.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-url

This should resolve your Vercel deployment errors. The build will work once Vercel can properly install all your dependencies from package.json!

Solved in DMs:
@sanity/client
was a missing dependency.

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?