Module not found: Can't resolve '@/components/OrderTable'
Next.js · updated 2026-11-03
Reported by the Next.js build (webpack or Turbopack) and by the dev server when an import path doesn't point at a file. The message shows the import as written and the file that contains it.
Failed to compile. ./app/orders/page.tsx Module not found: Can't resolve '@/components/OrderTable' https://nextjs.org/docs/messages/module-not-found
Quick fix
Check three things: the @/ alias exists in tsconfig.json (or jsconfig.json) with the right baseUrl and paths, the file name matches the import exactly including capitalization, and the file is inside the project the build sees. A build that works on macOS and fails on Linux is almost always capitalization.
- Open tsconfig.json and confirm paths has "@/*": ["./*"] (or ["./src/*"] if your code is in src/).
- Compare the import with the file name letter by letter: OrderTable vs orderTable.
- If you renamed only the case on macOS, git may not have recorded it: git mv the file to the new name.
- For packages, check the package is in dependencies and installed (not only in another workspace).
- Restart the dev server after changing tsconfig paths.
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}Why it happens
Capitalization that only macOS forgives
macOS file systems are case-insensitive by default, Linux build servers and Docker images aren't. import './Button' finds button.tsx locally and fails in CI.
A case-only rename git did not record
Renaming button.tsx to Button.tsx on macOS can leave git tracking the old name, so the repo still has the lowercase file and the build looks for the new one.
The path alias points at the wrong folder
Moving code into src/ without updating paths in tsconfig.json, or a monorepo package with its own tsconfig, makes @/ resolve to a folder without the file.
A package that is not installed where the build runs
A dependency only in devDependencies of another workspace, or missing from package.json because it was installed globally, resolves locally and not in CI.
Other fixes
- Turn on forceConsistentCasingInFileNames in tsconfig so TypeScript catches case mismatches before the build.
- For Node built-ins like 'fs' imported into client code, the fix is different: see Can't resolve 'fs'.
Same error, other wording
- Module not found: Can't resolve './components/Header'
- Module not found: Error: Can't resolve '@/lib/db' in '/app/src/app/api/orders'
- Module not found: Can't resolve 'date-fns'
Let your coding agent catch the next one
Runheed records this error in production with the stack trace, the breadcrumbs before it and the agent session that shipped the code, and serves it to Claude Code, Cursor or any MCP client. With it connected, you can ask:
> Find the 'Module not found: Can't resolve' build errors, show me each import and the actual file name on disk, and fix the capitalization, the tsconfig paths or the missing dependency.
Related errors
- Module not found: Can't resolve 'fs'
- Error: Cannot find module 'x'
- An error occurred in the Server Components render. The specific message is omitted in...
References: Next.js docs: module not found, Next.js docs: absolute imports and module path aliases