Skip to content
Latchkey

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.

turbopack
./app/page.tsx
Module not found: Can't resolve '@/components/Button'

https://nextjs.org/docs/messages/module-not-found

Common 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

  1. Confirm the alias works in tsconfig paths.
  2. Mirror it in the Turbopack resolveAlias config.
  3. Re-run the build so the alias resolves.
next.config.js
// 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.

Terminal
npm ci

How 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.

Frequently asked questions

What causes "Turbopack "Can't resolve""?
An alias like @/ defined in tsconfig may need a matching resolveAlias for Turbopack so it resolves the same way.
How do I fix Turbopack "Can't resolve"?
Configure the alias for Turbopack

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card