Skip to content

Security basics

"Failed to load module script": the blank page after a deploy

Failed to load module script and a blank page after a deploy: how to tell if one visitor or every visitor sees it, and the fix for each case.

Vlad Tkachenko11 min read
A browser window gone blank, and in front of it a plate holding a menu card where a dish of code should be.

In short

  • "Failed to load module script" means Chrome asked your host for one of your app's JavaScript files and was sent a web page instead. On a host that answers unknown addresses with your app's page, that is what a missing file looks like.
  • Who sees the blank page decides the fix. If a fresh private window loads the app, old copies of the page are asking for files the deploy removed. If the private window is blank too, the page your host serves names a file that is not there.
  • To tell which, open the script's address with view-source: in front of it. Code means the file is there. Your own page's HTML means it is missing.

You published an update, Vercel finished a build, or you moved your app to a new host, and now it opens on a white page with nothing on it. Press F12, open the Console tab, and there is one red line, starting with "Failed to load module script":

Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.

Older versions of Chrome say "a JavaScript module script", without the "-or-Wasm", and that is the wording older answers quote. Both mean the same thing.

The message names a server setting, the MIME type, so changing that setting looks like the fix. Before you touch it, find out who sees the blank page. The same red line has two causes with opposite fixes. In one, people who had your app open before the deploy are holding an old copy of the page, and it asks for files the deploy removed. In the other, the page your host now serves names a file that is not there, and every visitor gets the white screen. Clearing your cache fixes the first for you alone and does nothing for the second.

This post is about apps that draw themselves in the browser from JavaScript, which is what Vite builds. Lovable's documentation says its older apps "use React + Vite and render in the browser", and that apps created from 13 May 2026 use TanStack Start, which renders pages on the server. A Bolt, Cursor or Claude Code project may use Vite too. If your page source has a line starting <script type="module" that points at /assets/index-, this is your app.

Think of that page as a menu. It holds almost nothing itself: an empty space where the app will go, and a list of the script files that fill it, each named with a code such as index-4f2a.js. The browser orders every file on the list from the kitchen, which is your host, and runs what comes back. When you change your code, Vite gives the changed files new codes, so every deploy brings a new menu with new names on it.

What does "Failed to load module script" mean?

It means Chrome asked for one of your app's JavaScript files, and your host sent back a web page with an answer that said OK.

A MIME type is the label a server puts on whatever it sends: text/javascript on code, text/html on a web page. Chrome checks that label before it runs a module script, the kind of JavaScript file Vite builds. Chrome's source explains the rule in a comment: an ordinary script is not checked, for historical reasons, and "In contrast, module scripts will fail to load if they are not of a correct MIME type." A file labelled text/html fails the check, Chrome prints the red line, and the script never runs. When that script is your app's main one, nothing fills the empty space on the page. That is the white screen.

Chrome's source prints this message only after the answer has passed its status check. A file your host reports as missing, with a 404, gives a different error. So your host did answer, and what it sent was a page where your script should have been. In the kitchen, Chrome ordered a dish and was handed the menu.

Why does a missing file come back as your page?

Because apps like yours need one house rule at the host, and that rule catches missing files too.

Your app has addresses such as /settings or /orders/42 that exist only in the browser. There is no file called settings on your host. For somebody to open one of those addresses directly, the host has to answer it with your page and let the app work out the rest. Vercel's guide to Vite apps says that without this, "deep linking won't work out of the box", and gives the rule: rewrite every address to /index.html.

Vercel looks for a real file first. Its documentation puts it as "precedence is given to the filesystem prior to rewrites being applied", so a script that exists is sent as itself. A script that does not exist falls through to the rule and comes back as your page, labelled text/html, with an OK. The kitchen answers anything missing from its shelf by handing over the menu. That is the right answer for somebody asking for a table, and the wrong one for somebody who ordered a dish.

A missing script falls through the host's rewrite rule and comes back as your page, with a 200. Chrome refuses to run a page as a module script, and the app never draws.

So read the type in quotes before anything else. text/html is a page where a script should be. Another type there, such as text/plain, is a different problem: the file arrived under the wrong label, and that one is a server setting.

Is it only you, or every visitor?

Open the app somewhere that has never seen the old page. If it loads there, the blank screen belongs to old copies. If it is blank there too, every visitor gets it.

  1. Open your app in a private window. It does not share the stored pages of your normal window.
  2. Open it on your phone over mobile data.
  3. If both are blank, the page your host serves now names a file that is not there. If both load, the old page lives in browsers that had your app open before the deploy, yours included.
What you seeWhat it meansWhere the fix is
Blank in your usual window, fine in a private oneYour browser kept the page from before the deployReload now, then send the page with Cache-Control: no-cache
Fine until a click, then "Failed to fetch dynamically imported module"An open tab asked for a part the deploy removedReload now, then add a reload on vite:preloadError
Blank everywhere, <!doctype html> in the view-source test belowThe page names a file your host does not haveVite's base, the assets folder, or a cache in front of your host

One case sits between the rows. Vite's documentation tells you to send the page with Cache-Control: no-cache, "otherwise the old assets will be still referenced". Without that header, a browser may reuse the old menu, and a cache in front of your host may hand the old page to everybody it serves until it lets go of it. The same header fixes both.

How do you check whether the script file exists?

Open the script's address with view-source: in front of it, and read the first line that comes back.

  1. Open your app and press Ctrl+U, or Cmd+Option+U on a Mac, to see the page source.
  2. Find the line that starts <script type="module". The address after src= is your main script, something like /assets/index-4f2a.js.
  3. In a new tab, type view-source: and then the whole address: view-source:https://yourapp.com/assets/index-4f2a.js. With view-source: in front, Chrome shows you the text that came back and does not try to run it.
  4. Read the first line. A dense wall of code means the file is there. <!doctype html> followed by your app's title means it is missing, and your host sent your page in its place.
The same address, two answers. Code means the script is on your host. Your own page's HTML means it is missing and the host sent the page in its place.

If the main script comes back as code, repeat the test for any other .js address in the page source.

Why do only some visitors see a blank page after a deploy?

Because their browser is still using the page from before the deploy, and that page asks for files the deploy removed.

Vite's documentation describes it: "When a new deployment occurs, the hosting service may delete the assets from previous deployments. As a result, a user who visited your site before the new deployment might encounter an import error." A visitor with your app open in a tab is holding the old menu. Whatever already loaded keeps working, so they meet the problem when they click to a part of the app that loads on demand. The Console then shows the error Vite's documentation lists under its own heading, "Failed to fetch dynamically imported module".

For the people seeing it now, a reload is the fix: it fetches the new page, and the new page names files that exist. For the next deploy, two changes from Vite's documentation keep it from reaching anyone:

  1. Send the page with Cache-Control: no-cache. The header tells browsers to check for a new page every time before they reuse the old one. On Vercel, response headers are set in the headers section of vercel.json. Other hosts have their own place for them.
  2. Reload once when a part fails to load. Vite fires an event called vite:preloadError when a part of the app does not load, and its documentation shows a listener that reloads the page. The version below reloads once per tab, so a file that is missing for everyone cannot send the page round in a loop. Ask your builder to add it to the app's entry file, usually src/main.tsx:
window.addEventListener('vite:preloadError', () => {
  if (sessionStorage.getItem('reloaded-for-deploy')) return
  sessionStorage.setItem('reloaded-for-deploy', '1')
  window.location.reload()
})

Vercel sells a fix of its own on the Pro and Enterprise plans, Skew Protection, which keeps an open tab loading files from the deployment it came from. The frameworks it lists are Next.js, SvelteKit, Qwik, Astro, Nuxt and React Router. A plain Vite app is not among them.

Why is the page blank for every visitor?

Because the page your host serves now names a script at an address where there is none. Three things put it there. Check them in this order:

  1. Your app lives in a folder, and Vite thinks it lives at the top. A GitHub Pages project site sits at username.github.io/repo/, and Vite's deployment guide says to set base to '/repo/' in vite.config.js. Left at its default, /, the page asks for /assets/index-4f2a.js at the top of the domain, where there is nothing. In the kitchen, the menu sends every order to a counter that does not exist.
  2. The assets folder did not arrive. Vite writes the finished app into a folder called dist, with your page at the top and the scripts in assets beside it, and its guide says to deploy that whole dist folder. If you moved hosts by uploading files yourself, check that assets went up with index.html.
  3. A cache in front of your host still has the old page. The view-source test then shows an old script name that your latest build no longer has. Clear that cache, and send the page with Cache-Control: no-cache from now on.

Each fix ends the same way: deploy again, open the app in a private window, and run the view-source test once more.

Once the page loads again, our free scan reads the script files that deploy published, the same ones every visitor downloads. It reports a secret key it finds inside them, and source maps published beside them (a source map turns that compressed code back into the source you wrote, and Vite publishes them when build.sourcemap is switched on). It takes about 20 seconds and needs no account: scan your app.

Checking what each deploy publishes

Every deploy publishes a new set of script files, and those are the files our scan reads.

The free scan reads your live site the way a visitor's browser does.

  • It opens the script files your page loads and reports a secret key inside them.
  • It reports source maps published beside them.
  • There is no account to make and nothing to install.

Scan your app free in 20 seconds

Reeve Monitor runs that security check every hour and tells you when your grade drops.

  • The alert names your grade before and after.
  • Alerts go out by email, Telegram, Slack or webhook.

See what Monitor checks

What to do right now

What to do

  • Read the type in quotes. text/html means your host sent a page where a script should be, so look for the missing file before you change any server setting.
  • Open the app in a private window and on mobile data. If it loads there, old copies of the page are the cause. If it is blank there too, the page your host serves is wrong.
  • Open the main script's address with view-source: in front. <!doctype html> on the first line means the file is missing.
  • For old copies, send the page with Cache-Control: no-cache, and reload once on vite:preloadError.
  • For every visitor, check Vite's base, that the assets folder was published beside your page, and any cache in front of your host.

If Chrome shows its own error page instead of a white one, it never got a page from your site at all, and what "This site can't be reached" means covers each code it prints.

FAQ

What does "Failed to load module script" mean?

Chrome asked your host for a JavaScript file, and what came back was labelled text/html, a web page. Chrome refuses to run a page as a module script. When the refused file is your app's main script, nothing draws the app and the page stays blank.

Why is my Vite app a blank page after I deployed?

Either some browsers still hold the page from before the deploy and it asks for files the new build replaced, or the page your host now serves names a script that is not at that address. Open the app in a private window. If it loads there, it is the first. If it stays blank, it is the second.

Will clearing my cache fix "Failed to load module script"?

Only when the old copy of the page is in your own browser, and then a reload does the same job. It does nothing for a script that is missing from your host, and nothing for your visitors, who each hold their own copy.

What is "Failed to fetch dynamically imported module"?

The same missing file, met later. Vite splits an app into parts that load when they are needed, such as the code for a screen you click to. When a deploy removes a part an open tab still asks for, this is the error Vite's documentation names, and reloading the page fixes it for that visitor.

Should I change the MIME type setting on my server?

Read the type in the message first. text/html means a web page came back where the script should be, and relabelling .js files would not put the file there. Check that the file exists by opening its address with view-source: in front of it.

Written by

Vlad Tkachenko

Founder, Reeve

I spend my time looking at apps built with Lovable, Bolt, v0, Cursor and Replit, and at the short list of mistakes that keep turning up in them.

More about the author

Read next

All articles

Not sure where your own app stands?

Run a free scan and get a plain-language grade from A to F in about 20 seconds. No account, no card.

Scan your app free

Automated external check, not a full audit. Absence of findings is not a guarantee of safety.