Skip to content
>_VibeUnstuck

Module not found on Linux, fine on Mac

Last verified:

The fix

The Mac build resolves Button.tsx and button.tsx as the same file. Vercel, Netlify, and other Linux builders do not, so the import fails with module not found.

  1. 1

    Compare the import to the path Git has stored

    Open the import the build log names and run git ls-files on the file you think it is. Every character has to match, including capitals in each folder. If git ls-files does not list the file at all, the import is wrong or the file was never committed. That is the other module-not-found page.

  2. 2

    Record a case-only rename with git mv

    Rename through a temporary name so Git stores the new case, then commit and push. A one-step git mv of only the capital letters can fail on a case-insensitive disk with fatal: renaming ... failed: Invalid argument or destination exists. git mv -f is enough for some files on current Git. Directories more often need the two-step rename. Do not add a second file that differs only by case.

    git mv components/Button.tsx components/button.tmp.tsx
    git mv components/button.tmp.tsx components/button.tsx
    git status
  3. 3

    Check core.ignorecase without flipping it globally

    Run git config --get core.ignorecase in the repo. true is what Git set because the Mac disk ignores case, and it explains why a Finder rename never showed up in git status. The fix Linux sees is the git mv commit, not this setting. The builder does not read it. Git's docs say changing it may result in unexpected behavior, so do not set --global. Setting core.ignorecase to false in this repo only can make git status show a case change. Leave it true if you are unsure. The pushed tree is what matters.

  4. 4

    Rebuild on the host

    Push the commit and let Vercel or Netlify build again. The log should resolve the same path git ls-files prints. If it still cannot find the module, the import points at a file that is not in the commit, or a package that is not in package.json. Fix that path. Do not add an empty stub so the build goes green.

Why it happens

A default Mac disk (APFS) is case-insensitive, so an import of ./Button and a file stored as button.tsx are the same path in dev. The Linux image that builds the site treats them as two paths. The bundler then reports Module not found: Can't resolve for a file you can open locally.

Git on that Mac usually has core.ignoreCase set to true. git clone and git init probe the disk and set it when the filesystem ignores case. Git's config docs call it an internal variable: if a directory listing finds makefile when Git expects Makefile, Git assumes it is the same file and keeps the name it already stored. While it is true, a rename you make in Finder often never changes the path Git will send to Linux. The docs also say Git relies on the right setting for your operating system and that modifying the value may result in unexpected behavior.

The next error you'll probably hit

Once this is fixed, the usual follow-up is Module not found: Can't resolve. Module not found: Can't resolve means the import path or package is not on disk, often after an AI edit. Fix the path or install the package, then restart.

Prompt to paste back into your AI tool

Paste this above the error.

The Next.js or Vite build passes on my Mac and fails on Vercel or Netlify with Module not found: Can't resolve '<path>'.

Do not create a second file that differs only by letter case. Do not set git config --global core.ignorecase. Do not add an empty module to silence the bundler. Do not change tsconfig unless the alias itself is wrong.

1. Compare the import string to `git ls-files` for that path. Quote both.
2. If only the capital letters differ, rename with git mv through a temporary name, then commit. A Finder rename is not enough when core.ignorecase is true.
3. You may show `git config --get core.ignorecase`. Explain that true is normal on a case-insensitive Mac disk. Do not change it globally. Git's docs say modifying it may result in unexpected behavior.
4. If the file is actually missing, say so and stop. Touch only the import and the filename case.

Common questions

+I renamed the file in the editor and git status is clean. Why does Linux still fail?

On a case-insensitive disk, Git with core.ignorecase true keeps the old capital letters in the index. git ls-files shows the name the builder will receive. Rename with git mv through a temporary name and commit that.

+Should I set core.ignorecase to false so this stops happening?

Git sets it true on purpose when the filesystem ignores case, and the config docs say changing it may result in unexpected behavior. Check it to understand a missing rename. Record the new case with git mv. Do not set the option globally.

Related errors