Module not found: Can't resolve 'x' (Next.js build) Next.js Origin: On your device OSI layer 7 · Application Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: Next.js Node.js

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

  1. Match the exact file name case
  2. Define paths: { "@/*": ["./src/*"] } in tsconfig.json
  3. npm install PACKAGE and commit lockfile

Detailed fix by platform

Next.js

  1. git ls-files | grep -i button to compare real file name case; npm ls PACKAGE

How to diagnose

  1. Path — Case and extension?
  2. Alias — tsconfig paths?
  3. 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:

Where this error sits

Origin: On your device. Errors that are often confused with or caused by this one (click to open):

[Vue warn]: Component is missing template or render function — Vue: [Vue warn]: Component is missing template or render function. (Vue)[Vue warn]: Component…Can't resolve 'fs' — Module not found: Can't resolve 'fs' (Next.js / webpack 5) (React)Can't resolve 'fs'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" (Vue)Component provided te…Could not find a production build in the '.next' directory — Next.js: Error: Could not find a production build in the '.next' directory. Try building your app with 'next build' before starting the production server (Next.js)Could not find a prod…Element type is invalid — Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined (React)Element type is inval…Failed to compile: ESLint errors during next build — Next.js: Failed to compile. ./src/app/page.tsx 12:7 Error: 'x' is assigned a value but never used. @typescript-eslint/no-unused-vars (Next.js)Failed to compile: ES…Failed to fetch font from Google Fonts — Next.js: ⨯ Failed to download `Inter` from Google Fonts. Using fallback font instead / FetchError: request to https://fonts.googleapis.com failed (Next.js)Failed to fetch font …Feature flags __VUE_OPTIONS_API__ not explicitly defined (esm-bundler) — Vue: You are running the esm-bundler build of Vue — configure your bundler to explicitly replace feature flag globals (__VUE_OPTIONS_API__) (Vue)Feature flags __VUE_O…Module no…

Explore the map of this error Full error map →

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