Next.js: Module not found: Can't resolve '@/components/Button' / 'lodash' in '/app/src'
Webpack/Turbopack couldn't resolve an import — wrong path/alias, missing dependency or case mismatch.
Module not found: Can't resolve '@/components/Button'Module not found: Can't resolve 'lodash'Module not found: Error: Can't resolve './Button' in '/app/src'Failed to compile. Module not found: Can't resolve./src/app/page.tsx Module not found: Can't resolve Meaning
Check the import path and file name case (Linux is case-sensitive: Button.tsx vs button.tsx), that the alias (@/) is defined in tsconfig.json paths/jsconfig.json, and that the package is in dependencies (not only installed locally). CI builds often fail due to case differences or missing devDependencies.
Common causes
- Case mismatch in file name (macOS vs Linux)
@/alias not configured- Package not installed or only in devDependencies pruned in prod
- Wrong relative path
- Missing file extension/index file
⚡ Quick fix
- Match the exact file name case
- Define
paths: { "@/*": ["./src/*"] }in tsconfig.json npm install PACKAGEand commit lockfile
Detailed fix by platform
Next.js
git ls-files | grep -i buttonto compare real file name case;npm ls PACKAGE
How to diagnose
- Path — Case and extension?
- Alias — tsconfig paths?
- Package — In dependencies?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- [Vue warn]: Component is missing template or render function Vue: [Vue warn]: Component is missing template or render function.
- Can't resolve 'fs' Module not found: Can't resolve 'fs' (Next.js / webpack 5)
- Component provided template option but runtime compilation is not supported Vue: [Vue warn]: Component provided template option but runtime compilation is not supported in this build of Vue. Configure your bundler to alias "vue" to "vue/dist/vue.esm-bundler.js"
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026