"Module not found" after deploy: case-sensitive imports on Linux
THE SHORT ANSWER
If the build works on your Mac or Windows machine and fails on the server with "Module not found: Can't resolve './components/button'", Vite's "Could not resolve", or Node's ERR_MODULE_NOT_FOUND, check letter case first. macOS and Windows disks ignore case by default, so ./button finds Button.tsx locally; Linux servers don't. Either the import's case is wrong, or you renamed the file by changing only its case and Git still has the old name, because Git on those systems ignores case-only renames. Run git ls-files | grep -i button to see the name the server gets, fix the import or rename with git mv (two steps for a folder), commit, and redeploy.
What does the error look like?
The project has components/Button.jsx, and a page imports ../components/button. On a Linux build machine, each tool reports it in its own words:
# Next.js 16 (Turbopack and webpack) ./app/page.jsx Module not found: Can't resolve '../components/button' # Vite 7 Could not resolve "./components/button" from "src/main.js" # Node.js, ES modules Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/src/utils/helper.js' imported from /app/src/index.js # Node.js, require() Error: Cannot find module './utils/helper.cjs'
All four come from the same place: the file system was asked for button and only has Button. On macOS and Windows, which ignore case by default, the same lookup succeeds. We ran the Vite build and the Node script above on a Mac disk and both worked, then ran them on a Linux disk and got these errors. That's why the bug survives every local test and appears on the first deploy.
The error names the import that failed. If the path is a package name rather than a file (Can't resolve 'dotenv'), case is rarely the problem; check that the package is in package.json. For Python's version of this, see ModuleNotFoundError after deploy.
Which of the two causes is it?
There are two ways to end up here, and they need different fixes:
- The import is wrong. The file is
Button.tsxin Git and on your disk, and some import says./button. Fix the import. - Git has the old name. You renamed
button.tsxtoButton.tsxin your editor or Finder. Your imports match the new name, but Git never recorded the rename, so the server getsbutton.tsx. Fix the name in Git.
Ask Git which name it has. Whatever git ls-files prints is exactly what the server clones:
git ls-files | grep -i button # components/button.tsx <- the server has this ls components # Button.tsx <- your disk shows this
If the two disagree, it's cause 2. If they agree, search the code for the import with the wrong case (grep -rn "components/button" src).
Why doesn't Git see a case-only rename?
When you create or clone a repo on a case-insensitive disk, Git sets core.ignoreCase to true. Git then treats button.tsx and Button.tsx as the same file. Rename one to the other outside Git and git status shows nothing to commit. We checked with Git 2.50 on macOS: after a plain mv, the working tree looked clean.
Rename through Git instead. For a file, one step works:
git mv components/button.tsx components/Button.tsx git status # renamed: components/button.tsx -> components/Button.tsx git commit -m "Rename button.tsx to Button.tsx"
A folder fails in one step on macOS:
git mv Components components # fatal: renaming 'Components' failed: Invalid argument
Go through a temporary name:
git mv Components components-tmp git mv components-tmp components git commit -m "Rename Components/ to components/"
Don't fix it by setting core.ignoreCase false on a Mac. The disk still can't hold two names, so Git starts tracking both button.tsx and Button.tsx, and the Linux checkout gets two files. If that already happened, this lists the duplicates:
git ls-files | sort -f | uniq -di
Remove the wrong one from the index with git rm --cached path/to/button.tsx and commit.
How do you catch it before deploying?
A few checks that fail on your machine instead of on the server:
- TypeScript reports it when the file is also part of the project through
include, which is the usual setup.forceConsistentCasingInFileNamesis on unless you turn it off. In our test, TypeScript 5.9 on macOS printed:Runerror TS1149: File name '/app/components/button.ts' differs from already included file name '/app/components/Button.ts' only in casing.
npx tsc --noEmitbefore you push. - ESLint with
eslint-plugin-import: theimport/no-unresolvedrule reports imports whose case doesn't match the file on a case-insensitive disk, through itscaseSensitiveoption, which defaults to on. - Build on Linux once. Copy the project into a container rather than mounting it. A bind mount from a Mac keeps the Mac's case-insensitive behavior, and the build passes when it shouldn't:
docker run --rm -v "$PWD":/src:ro node:22 \ sh -c 'cp -r /src /app && cd /app && rm -rf node_modules && npm ci && npm run build'
- Pick one naming rule for files, such as PascalCase for components and kebab-case for everything else, so the right case is easy to guess.
What happens on EthioDeploy?
Builds run on Linux servers, so a case mismatch fails the build with one of the errors above, in the build log. Nothing is deployed and the previous version keeps serving. Fix the import or the name in Git, push, and the new commit deploys.
If the error names import.meta.env or a variable rather than a file, it's a different problem: see Vite env variables undefined in production. Setup for each framework is in the Next.js and Node.js deploy guides.
Questions
Most often an import's letter case doesn't match the file name. macOS and Windows ignore case by default, so ./button finds Button.tsx there, while the Linux build machine doesn't. Fix the import or the file name, and make sure Git has the new name.
Use git mv old new, for example git mv button.tsx Button.tsx, then commit. A plain rename in your editor isn't recorded on macOS or Windows because core.ignoreCase is true. For a folder, rename through a temporary name in two git mv steps.
Run git ls-files | grep -i name. That prints the path as stored in the repository, which is what the server checks out, even when your disk shows a different case.
Not on a case-insensitive disk. Git can then track two files that differ only in case while your disk holds one of them, and the Linux checkout gets both. Use git mv for case-only renames instead.
Yes, when the file is also included in the project, which is the default with include globs. TypeScript reports TS1149, "differs from already included file name only in casing", unless forceConsistentCasingInFileNames is set to false.
Sources
Checked on November 29, 2026:
Push a repo. Get a URL.
- Deploy a Next.js app
- Deploy a Node.js app
- Vite env variables undefined in production
- ModuleNotFoundError after deploy
Join the EthioDeploy Telegram
Release notes as they ship, plus deploy help from the team and other developers.