Fix guides / Vercel build: "Module not found: Can't resolve"

Vercel build fails with "Module not found: Can't resolve": how to fix it

Everything works on your laptop. You push, Vercel runs the build, and it stops with Module not found: Can't resolve followed by a file or package name. These are the causes we see most, in order.

1. File name casing (the most common one)

macOS and Windows treat Button.tsx and button.tsx as the same file. Vercel builds on Linux, where they are different. If you import ./components/button but the file is Button.tsx, it works locally and fails on Vercel.

Fix: make the import match the file name exactly. If you renamed a file only by changing its case, Git may not have noticed. Force it:

git mv components/button.tsx components/Button.tmp.tsx
git mv components/Button.tmp.tsx components/Button.tsx
git commit -m "Fix file name casing"

2. A package is installed locally but missing from package.json

If the error names a package (for example Can't resolve 'framer-motion'), it is probably installed on your machine but not saved as a dependency. Run:

npm install framer-motion
git add package.json package-lock.json
git commit -m "Add missing dependency"

Also make sure only one lockfile is committed. Having both package-lock.json and pnpm-lock.yaml or yarn.lock can make Vercel pick a different package manager than you use.

3. Path aliases like @/components

Imports such as @/lib/utils need an alias in tsconfig.json (or jsconfig.json) and, for Vite, in vite.config.ts too:

// tsconfig.json
{ "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./src/*"] } } }

// vite.config.ts
import path from 'path';
export default defineConfig({
  resolve: { alias: { '@': path.resolve(__dirname, './src') } }
});

Check that the path in the alias matches your folders. Next.js apps without a src folder usually need "@/*": ["./*"].

4. The file was never committed

Run git status and check .gitignore. A file that exists only on your machine does not exist on Vercel.

5. Wrong root directory

If your app lives in a subfolder (common with exports from AI builders), set Root Directory in Vercel Project Settings, then General, to that folder.

Reproduce the Vercel build locally

rm -rf node_modules .next dist
npm ci
npm run build

npm ci installs only what the lockfile lists, which is much closer to what Vercel does. If the build fails here, you can fix it before pushing.

Still stuck? No shame in it: these bugs hide in settings your AI builder cannot see. Send us the error and your repo and we will fix it as a pull request within 24 hours, explained in plain English, for $49. Not fixed means full refund.
Request a fix

Last updated 2026-10-19.