應用程式部署出現「Could not resolve」錯誤,本機卻可正常運行
“Could not resolve” on deploy, but it works on my computer
應用程式部署時出現「Could not resolve」而本機可正常運行,常見原因是匯入路徑與檔名字母大小寫不一致,或檔案未提交。macOS 和 Windows 會把這類大小寫視為相同,Linux 建置環境則不會;可逐字比對匯入路徑與檔名,並確認檔案已提交到 GitHub repository。
The build fails with Could not resolve './components/navbar' while the app runs fine locally. Usually it's capital letters: Mac and Windows ignore them, the build server doesn't.
What you see
The deploy fails with Could not resolve "./components/navbar" from "src/App.tsx" (or Module not found: Can't resolve), yet npm run dev and npm run build work on your computer.
Why it happens
The import says navbar and the file is Navbar.tsx. macOS and Windows treat those as the same name; the Linux machines that build your app don't. AI tools write mismatched capitals easily, and nothing on your computer complains. The other cause: the file was never committed.
How to fix it
- Find the file the error names, and compare its name with the import letter by letter.
- Change the import to match the file's name exactly (or rename the file).
- To rename a file only by capital letters in git, use
git mv -f old new: a plain rename often isn't seen. - Check the file is in the repository on GitHub, not only on your computer.
Or ask your AI tool to fix it
Paste this into Lovable, Bolt, v0, Replit or Cursor:
My app builds on my computer but fails when deployed (on Linux) with "Could not resolve". Find every import whose path differs from the real file's name in capital letters, and make each one match the file exactly. Don't change anything else.
The full page, with the request ready to copy, is at launchpad.axonscape.com/fix/could-not-resolve-works-locally. I work on Launchpad by Axonscape, which runs a free launch check for apps built with AI tools: it finds this and the other things that break at launch, from a public GitHub repo or a .zip of the code, and keeps nothing.
來源:DEV Community · dev.to