HomeNext.js ChunkLoadError: Loading chunk failed after deploying.

Next.js ChunkLoadError: Loading chunk failed after deploying.

Published: 10/20/2023

Everything was working fine locally, but the whole console gets red with ChunkLoadError after you deploy to production. Moreover, the frontend becomes blank white and you see Application error: a client-side exception has occurred (see the browser console for more information). The issue seems to be here for a while, and it looks like no-one knows which part exactly is responsible for the error (Next.js or Webpack or both), but the workaround is present.

Here are the steps that helped in my situation:

  1. Remove any cache folders in your build steps. That is, any kind of .next/, out/, or any other folder that is not a part of the repository and not related to the application or configuration.
  2. Re-build your project and deploy to production.
  3. Disable browser cache completely and do a hard-refresh (Shift + R on Windows, or Cmd + Shift + R on Mac)

About Code with Node.js

This is a personal blog and reference point of a Node.js developer.

I write and explain how different Node and JavaScript aspects work, as well as research popular and cool packages, and of course fail time to time.