MELLEPRISE MELLEPRISE AI MP Blog
← All articles

Lovable export code won’t run? The download is fine β€” the runtime isn’t

Your lovable export code won’t run β€” you unzip it, open index.html, and stare at a blank page. The app that worked in preview an hour ago looks dead.

Or worse: npm run dev actually starts, the page loads, and then the app falls apart β€” sign-in spins forever, forms return errors, every screen that showed data is empty. The export is not broken. It is incomplete in a way nobody warned you about: Lovable’s runtime was feeding your app things that never made it into the download.

What the export actually contains

The lovable export code you get β€” via Git sync to GitHub or a zip β€” is source code. It is your React components, routes, styles and build config. It is not a self-contained copy of your app.

Three things stay behind:

  • Environment variables. Lovable injects values like your Supabase URL and publishable key into its own runtime. The exported code reads them from import.meta.env β€” locally, that is empty.
  • Backend services. Database rows, storage buckets and edge function secrets live in your Supabase project. None of that is in the zip.
  • The dev server. A single-page app needs HTTP. Double-clicking index.html gives you a file:// address with no routing and no bundler β€” a white page by design, not by bug.

Identify which failure you have

Same symptom, four different causes. Pick yours before fixing anything:

  1. Blank page from a double-click. Address bar starts with file://. Nothing was ever going to render β€” the app was never started.
  2. Dev server starts, app errors immediately. Console shows supabaseUrl is required or undefined env values. Your env vars are missing.
  3. App runs, login is dead, data is gone. Auth calls reach Supabase but fail, or point at a different project. Wrong or missing env vars again β€” see the supabase anon key article for which key belongs in client code.
  4. npm install fails or the build type is unfamiliar. Your project uses Bun, an unusual Node version, or the newer TanStack Start stack that ships server code β€” not a static Vite site.

Fix it: the click path

  1. Install Node.js LTS and check the project’s engines field or .nvmrc. A Vite template can demand more than your system default.
  2. Use the package manager the export declares. A bun.lock means Bun. Only a package-lock.json means npm. Mixing them produces dependency trees that build differently than the preview did.
  3. Run the app, don’t open it. In the folder with package.json: npm install, then npm run dev. Lovable’s default dev port is 8080, not Vite’s usual 5173 β€” open the address the terminal prints, not the one the README guesses.
  4. Recreate the env vars. In the project root, create .env with the values Lovable injected: VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY (or the publishable key) from Supabase Dashboard β†’ Settings β†’ API. Restart the dev server β€” Vite reads env vars at startup.
  5. Check which stack you exported. If package.json lists @tanstack/react-start, your project runs server code β€” it is not a static site, and connector or AI features need their backend env vars too. A plain React+Vite export builds to static files you can host anywhere.
  6. Point preview and live at the same project. If data is empty but auth works, your export may be talking to a different Supabase project than the preview. Compare the project ref in both URLs.

If the export came through Git sync rather than a zip, the lovable github article covers the clone path. When the app runs locally and the next blocker is hosting, the lovable deploy checklist is the same five settings in production order β€” and vercel env vars covers the identical problem on the host side: variables that never left your laptop.

Why the AI did not warn you

Inside Lovable, the app never needed a .env β€” the platform supplied it. The AI that assembled your project optimized for its own runtime, where these values exist by default. Exporting is the first moment your code meets a machine that is not Lovable, and everything that was ambient becomes visible as a missing piece.

That is also why the lovable export code failure feels total: env vars touch everything. One missing value produces a dead login, empty screens and failing forms at once, which looks like a broken export rather than one missing file.

Run checklist

  • Started with npm install + npm run dev, never via file://
  • Opened the printed port (usually 8080), not the assumed one
  • .env exists in the project root with the real Supabase URL and publishable key
  • Package manager matches the lockfile (Bun vs npm)
  • Node version matches engines / .nvmrc
  • TanStack Start projects: backend env vars set, not just the frontend ones
  • Export and preview point at the same Supabase project ref

A lovable export code that “won’t run” almost always runs β€” it is just waiting for the .env file nobody told it about.

FAQ

Can I open the exported index.html directly in the browser?

No. The export is a single-page app that must be served over HTTP. A file:// address has no dev server, no routing and no env vars, so you get a blank page. Run npm install and npm run dev in the project folder instead.

Why does login work in Lovable but fail in the export?

Lovable injects your Supabase URL and publishable key at runtime. The exported code reads them from env vars like VITE_SUPABASE_URL that are empty locally. Create a .env file in the project root with the same values, restart the dev server, and auth works again.

Does the export include my database, storage files and edge functions?

No. You get source code only. Database rows, storage objects and edge function secrets stay in your Supabase project β€” they are reachable from the export once the env vars point at the same project, but nothing is copied into the zip.