ChunkLoadError: Loading chunk 5 failed
The browser couldn’t download a code-split chunk. Usually a deployment or caching issue.
Fix 1: Hard refresh
Ctrl + Shift + R (Windows/Linux)
Cmd + Shift + R (Mac)
Fix 2: Clear old chunks on deploy
Make sure your deployment doesn’t delete old chunks before users have reloaded:
// Catch the error and reload
window.addEventListener('error', (e) => {
if (e.message.includes('Loading chunk')) {
window.location.reload();
}
});
Fix 3: Check your CDN/hosting
Make sure all chunk files are being served. Check the network tab for 404s.
Fix 4: Use content hashes
// webpack.config.js
output: {
filename: '[name].[contenthash].js',
chunkFilename: '[name].[contenthash].js',
}