Turbopack "Module not found: Can't resolve" in CI
Turbopack (used by Next.js builds) could not resolve an import. The package is not installed, a path alias is not configured for Turbopack, or the import case does not match the file on a case-sensitive runner.
What this error means
The build fails with "Module not found: Can't resolve 'X'" pointing at an import, even though it resolves locally.
./app/page.tsx
Module not found: Can't resolve '@/components/Button'
https://nextjs.org/docs/messages/module-not-foundCommon causes
A path alias not configured for Turbopack
An alias like @/ defined in tsconfig may need a matching resolveAlias for Turbopack so it resolves the same way.
A missing dependency or case mismatch
The package was not installed in CI, or the import case differs from the file on a case-sensitive runner.
How to fix it
Configure the alias for Turbopack
- Confirm the alias works in tsconfig
paths. - Mirror it in the Turbopack resolveAlias config.
- Re-run the build so the alias resolves.
// next.config.js
module.exports = {
experimental: {
turbo: { resolveAlias: { '@': './src' } },
},
};Install the dependency and match case
Ensure the package is installed and the import path matches the real file name exactly.
npm ciHow to prevent it
- Keep aliases consistent between tsconfig and Turbopack.
- Commit a lockfile so CI installs every import.
- Match import path case to real file names for Linux runners.