I am following a tutorial on building a web app with ASP.NET Core and Angular 12. After creating the first component I built the app I got the initial chunk files BUT minus the vendor.js. In the tutorial, the vendor.js file is actually among the chunk files and so I manually downloaded and added the vendor.js file. However, when I run the command 'ng build', the vendor.js file disappears from solution explorer. When I debug the app I get a blank page and the console message errors as shown in the image.
Later on, I read somewhere that vendor.js is used during production. Could this be the reason it disappears? Please let me know if you need more info to solve the problem.
Thanks
You say, you manually downloaded and added the vendor.js
file. I actually don't know why you do that manually.vendor.js
is a compiled file that angular generates for you. I will recommend you Update the node to the latest version and the Angular CLI version also upgrade the angular project version.
right now, I assume that your vendor.js
is too high so that you found this issue. follow the below process:-
run this command:- ng build --prod --vendor-chunk=true
or ng build --prod
Angular Should I use the vendorChunk in production if not work then try below process:-
Maybe like to be an issue with caching. Run this command:-
npm cache clean
or npm cache verify
or npm cache --force clean
Also, Update the node to the latest version and Angular CLI version.
if not work, then follow the second process:-
Change index.html <base href="/">
to <base href="./">
if not work, then follow third process:-
Add useHash:true in your route module
@NgModule({
imports: [
BrowserModule,
FormsModule,
RouterModule.forRoot(routes, { useHash: true }) // .../#/your-route/
]
...................
Hope it will resolve your issue.