12

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

5
  • What is the default route for LazyModule ? Commented Sep 19, 2017 at 8:15
  • app-routing.module.ts { path: 'lazy', loadChildren: './lazy.module#LazyModule'}, Commented Sep 19, 2017 at 8:46
  • hey its working by adding "deployUrl" : "/path", in apps in .angular-cli.json Commented Sep 19, 2017 at 12:43
  • 1
    This may also work for you then: stackoverflow.com/questions/38112891/… Commented Sep 19, 2017 at 19:54
  • it works when I change to "deployUrl":"path/" Commented Apr 27, 2018 at 21:13

6 Answers 6

10

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

Sign up to request clarification or add additional context in comments.

1 Comment

@KirillWarp can you please provide your issue in details
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.

Comments

3

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

1 Comment

This works for me. In my case this issue only occurs with firefox, chrome never show me this error with lazyload
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.

Comments

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.

Comments

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.