Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lazy loading issue : Loading chunk 0 failed

components in -- lazy.module.ts

 const routes: Routes = [
   { path: 'memberdetails', component: MemberDetailsComponent },
   { path: 'leaves', component: LeavemanagementComponent },
  { path: 'attendance', component: AttendanceComponent }
 ];

app-routing.module.ts

 const routes: Routes = [
   { path: 'lazy', loadChildren: './lazy.module#LazyModule'},
 ];

It's working locally, but after hosting it when I click on any of these above links I am getting this error...

vendor.05d559e….bundle.js:1 ERROR Error: Uncaught (in promise): Error: 
Loading chunk 0 failed.
Error: Loading chunk 0 failed.
at HTMLScriptElement.r (inline.9786b27….bundle.js:1)
at HTMLScriptElement.L (polyfills.1a7da64….bundle.js:1)
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at Object.onInvokeTask (vendor.05d559e….bundle.js:1)
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at r.runTask (polyfills.1a7da64….bundle.js:1)
at t.invokeTask [as invoke] (polyfills.1a7da64….bundle.js:1)
at h (polyfills.1a7da64….bundle.js:1)
at HTMLScriptElement.d (polyfills.1a7da64….bundle.js:1)
at HTMLScriptElement.r (inline.9786b27….bundle.js:1)
at HTMLScriptElement.L (polyfills.1a7da64….bundle.js:1)
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at Object.onInvokeTask (vendor.05d559e….bundle.js:1)
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at r.runTask (polyfills.1a7da64….bundle.js:1)
at t.invokeTask [as invoke] (polyfills.1a7da64….bundle.js:1)
at h (polyfills.1a7da64….bundle.js:1)
at HTMLScriptElement.d (polyfills.1a7da64….bundle.js:1)
at u (polyfills.1a7da64….bundle.js:1)
at u (polyfills.1a7da64….bundle.js:1)
at polyfills.1a7da64….bundle.js:1
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at Object.onInvokeTask (vendor.05d559e….bundle.js:1)
at e.invokeTask (polyfills.1a7da64….bundle.js:1)
at r.runTask (polyfills.1a7da64….bundle.js:1)
at o (polyfills.1a7da64….bundle.js:1)
at t.invokeTask [as invoke] (polyfills.1a7da64….bundle.js:1)
at h (polyfills.1a7da64….bundle.js:1)

Folder Structure:

enter image description here

like image 657
Hemanth Avatar asked Sep 19 '17 08:09

Hemanth


People also ask

How do I fix a chunk load error?

If you are encountering this error as a user of an application, the simplest way to resolve it is to clear your browser cache (and also restart it for good measure) and try again. If the error was because your browser had cached older files, this should fix the issue.

How overcome loading chunk failed with angular lazy loaded modules?

We can use global error handling and force the app to reload if chunks failed. For this, we need to create a GlobalErrorHandler class that implements an ErrorHandler class. All it does is just check the error message if it has a Loading chunk [XX] failed, and forces the app to reload and load the new fresh chunks.

What is Chunk error?

Chunk errors in Minecraft games are the corrupted visual blocks mismatching with the existing world.

What is a ChunkLoadError?

A "ChunkLoadError" generally means that a checksum failed for a javascript file. These errors occur when the browser requests a JS code chunk, and receives a response whose checksum does not match the expected “integrity=…” attribute associated with the <script> tag that refers to it.


2 Answers

Clean Your Cache or use CTRL + Shift + R combo key and try again!

like image 60
Sachin from Pune Avatar answered Oct 15 '22 18:10

Sachin from Pune


In my case The Ad Blocker Extension was creating this issue. Once i disabled it. The problem was solved

like image 44
Dhruv Patadia Avatar answered Oct 15 '22 17:10

Dhruv Patadia