← All errors · Next.js

Module not found: Can't resolve '...'

Exact error

Module not found: Can't resolve 'some-package'

What it means

The bundler could not locate an imported file or package.

Likely causes

How to fix it

  1. Install the package and make sure it is saved to package.json:

    npm install some-package
  2. Check the exact file name casing matches the import. Linux filesystems are case-sensitive. To fix a case-only rename in git:

    git mv components/button.tsx components/Button.tsx
  3. If you use the @/ alias, confirm it exists:

    // tsconfig.json
    { "compilerOptions": { "baseUrl": ".", "paths": { "@/*": ["./*"] } } }
  4. Only import fs/path in server code (Server Components, route handlers, getStaticProps).

Related errors

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy