angulartypescriptmigrationchunksangular13

ChunkLoadError: Loading chunk 552 failed


I am migrating the Angular 12 to 13, though the migration is successful but when I run project in the browser after successful build, It doesn't show the application. When I checked the console, it shows below error:

ChunkLoadError: Loading chunk 552 failed.

Also, It shows 2 files are not found, but when I checked in dist folder, those files exists:

enter image description here

Below is the error log in console:

enter image description here

I am not sure why it is showing this errors. I tried multiple solutions from the stackoverflow but no luck.

ng v enter image description here


Solution

  • Found a solution here: https://github.com/angular/angular-cli/issues/22113#issuecomment-1004279867

    I have to put following code in my main.ts file:

    declare var  __webpack_public_path__: string;
    __webpack_public_path__ = 'valueFormerlyAssignedUsing_deployUrl';
    

    Replace valueFormerlyAssignedUsing_deployUrl with your path to folder containing chunks.