How to Fix Next.js Module not found: Can't resolve
Last reviewed
Error message
Module not found: Can't resolve '<package-or-path>'.
Module-not-found errors look scary in CI logs, but the line number always points exactly at the import to fix.
What this error means
The Next.js compiler couldn't resolve an import path to either a node_modules package or a file on disk.
Why this happens
Missing dependency, dependency in devDependencies but needed at runtime, wrong-cased import path (Linux is case-sensitive), or a path alias not configured in tsconfig.
Quick fix (for end users)
- Check the spelling and casing of the import.
- Run `npm install <package>` if it's a missing dependency.
Admin / engineer fix
If the package is in devDependencies but used in app code, move it to dependencies.
commandnpm install <package> --saveCheck `paths` in tsconfig.json — alias-based imports require both a tsconfig entry and matching files on disk.
On Linux (Vercel runs Linux), 'Foo.tsx' and 'foo.tsx' are different files. Match casing exactly.
Step-by-step fix
Read the failing import path from the build log.
Confirm the package is installed and in dependencies (not devDependencies).
Check the casing and path on disk.
Affected products
Next.js · Vercel
Common variations of this error
People also see these phrasings of the same problem:
Cannot find moduleModule not found Next.js
Still broken? Try these
- Delete node_modules and package-lock.json, then `npm install` to rebuild.
- If using a monorepo with workspaces, confirm the workspace package is published or properly linked.
- Check `.gitignore` and `.vercelignore` — files might be excluded accidentally.
Related errors
Related searches
- next.js cannot resolve module
- vercel module not found
- next.js import path
Frequently asked questions
Why does it work locally on macOS?
macOS has a case-insensitive file system by default, so 'Foo.tsx' and 'foo.tsx' resolve the same. Linux (which Vercel uses) doesn't.
Browse more errors in Vercel: Fix Vercel deployment errors. Build failures, missing output directories, exceeded build duration, missing env vars, and module resolution issues. Or paste your own error into the error decoder tool to find a match. You can also go back to the homepage to browse common errors by topic.