← All errors · LovableLovable & Bolt app errors

TypeError: Failed to fetch dynamically imported module

Exact error

TypeError: Failed to fetch dynamically imported module: https://your-app.com/assets/Dashboard-XXXXXXXX.js

What it means

The browser could not download a lazy-loaded JavaScript chunk (a route or component loaded with import() or React.lazy). Lovable and Bolt apps are built with Vite, which code-splits into hashed chunk files. Most often the page was opened before a new deploy and is asking for a chunk that no longer exists. Firefox words it "error loading dynamically imported module" and Safari "Importing a module script failed."

Likely causes

How to fix it

  1. Hard-refresh the page (Cmd/Ctrl+Shift+R). If the error disappears, it was version skew after a deploy.

  2. Make the app recover automatically: in src/main.tsx, reload once when Vite reports a failed chunk (the guard prevents a reload loop if the chunk is truly broken):

    window.addEventListener('vite:preloadError', (event) => {
      const key = 'vite-preload-reload-at';
      const last = Number(sessionStorage.getItem(key) || 0);
      if (Date.now() - last < 10000) return; // reloaded recently, let the error show
      sessionStorage.setItem(key, String(Date.now()));
      event.preventDefault();
      window.location.reload();
    });
  3. If you host the exported app yourself (Vercel, Netlify, etc.), serve index.html with Cache-Control: no-cache so browsers always fetch the newest chunk list. Vite's docs recommend this alongside the vite:preloadError handler.

  4. If it happens on every load, open DevTools → Network and click the failing .js request: a 404 means the deploy or base path is wrong; a blocked request means an extension (test in a private window).

  5. In Lovable, paste the full error into chat (or use Try to fix) and mention it started after publishing.

Prevent this next time

FAQ

What does "TypeError: Failed to fetch dynamically imported module" mean?

The browser could not download a lazy-loaded JavaScript chunk (a route or component loaded with import() or React.lazy). Lovable and Bolt apps are built with Vite, which code-splits into hashed chunk files. Most often the page was opened before a new deploy and is asking for a chunk that no longer exists. Firefox words it "error loading dynamically imported module" and Safari "Importing a module script failed."

What usually causes it?

Version skew: you published a new version, the old hashed chunk files were removed, and a tab or cached index.html still points to them. index.html cached by the browser or CDN, so it keeps referencing old chunks. A flaky network or brief server outage while the chunk was loading. A browser extension such as an ad blocker blocking the chunk request.

How do I fix it?

1. Hard-refresh the page (Cmd/Ctrl+Shift+R). If the error disappears, it was version skew after a deploy. 2. Make the app recover automatically: in src/main.tsx, reload once when Vite reports a failed chunk (the guard prevents a reload loop if the chunk is truly broken): 3. If you host the exported app yourself (Vercel, Netlify, etc.), serve index.html with Cache-Control: no-cache so browsers always fetch the newest chunk list. Vite's docs recommend this alongside the vite:preloadError handler. 4. If it happens on every load, open DevTools → Network and click the failing .js request: a 404 means the deploy or base path is wrong; a blocked request means an extension (test in a private window). 5. In Lovable, paste the full error into chat (or use Try to fix) and mention it started after publishing.

Related errors

More Lovable errors and fixes →

Get new fixes weekly

No spam. Unsubscribe anytime. Privacy