Fix guide · updated 2026-11-08
Lovable build unsuccessful: find the real error and fix it without burning credits
Fix build errors · failed to resolve import · is not exported by · Publishing failed
Your Lovable build failed. The chat shows an error with a Try to fix button, the Publish dialog says Fix build errors instead of letting you publish, or a publish ends with Publishing failed. Pressing Try to fix over and over is the expensive way out. A failed build often comes down to one line in one file, and the error message says which. Here's how to read it and fix the cause.
Before you press Try to fix again
Try to fix is a good first move: Lovable scans the logs, finds the issue and attempts a fix. Your account gets 10 free fixes, shared between Try to fix and the fixes in the Security view, across all your workspaces and projects. Each one comes back 24 hours after you use it. Once all 10 are used, Try to fix still works, but it costs credits like any other build request. Where else the button shows up, and which problems it can't fix: Lovable Try to fix button.
Lovable's own debugging guide says to use it once or twice. If the same error comes back, or a new one takes its place, the fix isn't reaching the cause. Stop there and read the error yourself.
1. Find the real error
- Look for a file path and a line number, like
src/App.tsx:8. That's where the build stopped. In Lovable projects,@/in an import means thesrc/folder:@/components/Buttonis the filesrc/components/Button.tsx. - Fix the first error. One broken line can produce several errors. In our tests, a single missing closing tag gave two.
- Publishing blocked? When a publish fails on a build error, the Publishing failed banner shows a short summary of that build error.
Then go to that line:
- On a paid plan, open the Code tab, go to the file and line, and fix it yourself. Editing code by hand costs no credits, and each save becomes a version you can revert. On the Free plan the editor is read-only. You can still read the file and point Lovable at the exact line: hover the line number and click + to put a reference like
App.tsx:8in the chat. - If the project syncs with GitHub, run the same build on your computer to see the full output (you need Node.js). Fix the file, commit, and push to the synced branch:
If your pushes never show up in Lovable, see Lovable GitHub connection not working.npm install npm run build
Red underlines alone don't fail the build. Both Lovable templates build with vite build, which strips TypeScript types without checking them. We checked the build script in 40 public Lovable repositories, then planted a type error in a test app: it built. A failed build means Vite hit something it can't get past. Here are four common ones, with their exact wording. Most older Lovable projects build with Vite 5. Newer projects, on TanStack Start (the default since May 13, 2026), build with Vite 8, which words the same errors differently. We reproduced each one on both versions.
2. "Could not load" or "Could not resolve" one of your files
[vite:load-fallback] Could not load …/src/components/button (imported by src/App.tsx): ENOENT: no such file or directory
Could not resolve "./components/button" from "src/App.tsx"
The first comes from an @/ import, the second from a relative one like ./components/button. On newer projects: [UNLOADABLE_DEPENDENCY] Could not load src/components/button and [UNRESOLVED_IMPORT] Could not resolve './components/button' in src/App.tsx.
A file imports another file that isn't there under that name. Usually a file was renamed, moved or deleted, and an import somewhere still uses the old path. Compare the import with the file list in the Code tab, letter by letter: capital letters count. For the build, button and Button.tsx are different files, even though Mac and Windows treat them as the same.
That difference bites when you edit on a Mac or a Windows PC and push to GitHub. Rename Button.tsx to button.tsx in Finder or Explorer and Git keeps recording the old name, because on those systems it treats the two names as one file. The app runs on your computer, and Lovable's build fails. Rename with Git instead, then commit and push:
git mv src/components/Button.tsx src/components/button.tsx
3. "Failed to resolve import" for a package
[vite]: Rollup failed to resolve import "date-fns" from "…/src/App.tsx".
This is most likely unintended because it can break your application at runtime.
On newer projects, the same message starts with Rolldown failed to resolve import.
The code uses a package that isn't installed: it's missing from package.json. That happens when an edit adds the import but not the package, or when someone removes a package that's still in use. Ask Lovable to add that exact package to the project. With GitHub, run npm install date-fns (with your package's name), then commit package.json and the lock file.
Check the name first. If the package doesn't exist on npmjs.com under exactly that name, the import was a mistake. Fix the import instead of installing a look-alike: anyone can publish a package under a name that sounds right.
4. "Transform failed", "Unexpected token" or "Unexpected end of file"
[vite:esbuild] Transform failed with 2 errors:
…/src/App.tsx:8:0: ERROR: The character "}" is not valid inside a JSX element
…/src/App.tsx:9:0: ERROR: Unexpected end of file before a closing "main" tag
On newer projects: Unexpected token. Did you mean {'}'} or }?, followed by the file and line.
A file isn't valid code anymore: a missing closing tag, bracket or quote, often from an edit that stopped halfway. The file and line in the message are where the parser gave up, so the real slip is often on that line or just above it. In our test, the missing </main> belonged on line 7. If the file was fine one version ago, open History, use View code changes on the last version to see what changed, and put the missing piece back. Or revert that version (section 6).
5. "is not exported by"
"Buton" is not exported by "src/components/Button.tsx", imported by "src/App.tsx".
On newer projects: [MISSING_EXPORT] "Buton" is not exported by "src/components/Button.tsx".
The file exists, but the name you import isn't in it. A function or component was renamed or removed in one file, and another file still imports the old name. Fix the import to the current name, or bring the export back. If one name changed everywhere but one file, search the project for the old name (Search code in the Code tab finds every place that still uses it).
6. When fixes go in circles: plan, then roll back
If every fix brings a new error, ask before you build. Switch to Plan mode, which investigates without touching your code (one credit per message, plus any research it runs), and use the prompt Lovable's docs suggest:
What is the root cause of this build error? Show me the relevant code and explain what is going wrong before proposing a fix.
Rolling back is often faster than untangling a pile of fixes. Open History in the top bar, find the last version that built, and click Revert. The version that's live on your site carries a Published badge: it built, so it's a safe point to return to. Then ask for the change again, in smaller steps. Three things to know:
- Revert restores your code only, and redeploys your edge functions to match. It doesn't undo database changes made since that version.
- Credits spent on the messages you roll back aren't refunded.
- Very old versions can be previewed but not restored: the button says Cannot revert this far back in history.
7. The preview works, but publishing fails
The Publish dialog names the kind of failure in its Publishing failed banner. Each one has its own way out:
- Temporary issue (a timeout, a rate limit): click Try again. Retries usually succeed.
- Error in your app: a build error or an edge function that couldn't be deployed. Click Try to fix, or fix it yourself with the sections above.
- Configuration issue in your project, for example a file too large to include: click Try to fix.
- External connection or secret, such as an expired Supabase connection or a connected service that hit its plan limit. Lovable can't change those for you: reconnect the integration or raise the limit, then click Try again.
- A database change conflicts with existing data: click Ask Lovable. It confirms with you before touching anything, because the fix changes real data. Read that step carefully.
- Internal error: the problem is on Lovable's side. Try again in a few minutes. If it keeps failing, contact Lovable Support with your project link.
If the build passes but the app shows a blank page or a 404 once deployed, for example on Vercel, that's a different problem: see Lovable app: blank page or Vercel 404 after deploy.
Still stuck?
Check status.lovable.dev: during an incident in Lovable's build pipeline, builds can fail for everyone until it's fixed. If you're on a paid plan and believe the problem is on Lovable's side, contact Lovable Support. Otherwise, write down the first error, the file and line, and what you've tried. That's what anyone helping you will ask for first.
Other Lovable app problems? See Fix a Lovable app.