11

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

David Buck
  • 3,594
  • 33
  • 29
  • 34
Hemanth
  • 183
  • 1
  • 3
  • 18

6 Answers6

9

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

Sachin from Pune
  • 547
  • 6
  • 16
7

The CTRL + Shift + R hard reload helped in my particular case because my issue was that I made design changes and needed the hard reload. Not sure if it will solve this error in all cases.

Chaster johnson
  • 135
  • 1
  • 6
2

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

Dhruv Patadia
  • 112
  • 10
  • This works for me. In my case this issue only occurs with firefox, chrome never show me this error with lazyload – user739DamQ Jan 19 '21 at 12:59
0

We have faced the same issue recently in Angular builds. We are using Angular 7+. The reason was indeed the Cache. But in our case it was CloudFront based cache. So my suggestion is, if you face any such issue clean all types of cache as:

  1. Domain specific ( e.g; CloudFlare)
  2. Any CDN cache - e.g; CloudFront of AWS - Later we have implemented the solution where any new deployment pipeline will automatically refresh the CloudFront caching. Now there is no need of manual cache purging.
  3. Web server based cache - Apache or IIS
  4. User browser cache.

Some of the articles on Medium.com has mentioned about writing a service/directive to notify the build changes. we have not implemented it but it seems promising to me.

If this does not fix the issue, try to clean the package cache from the builder as well. Like we have GitLAb CI based pipelines that also creates such issues, to fix which, we have disabled the caching of the source code/packages at the GitLab runner.

Rupendra
  • 588
  • 2
  • 10
  • 40
0

We experienced the same issue in our localhost server. The reason was an invalid certificate in chrome and other browsers. We changed an option in Chrome.

This option will only work for requests to localhost over HTTP.

In the Chrome address bar, type chrome://flags/#allow-insecure-localhost and then select the “Enable” link.

PariSh KhAn
  • 535
  • 2
  • 6
  • 14
0

Checking Disable cache from the Developer tools

enter image description here

Then press Ctrl + F5 and CTRL+SHIFT+R multiple times solved the problem

Hakan Fıstık
  • 14,367
  • 10
  • 94
  • 117