Troubleshooting Angular production build errors — Uncaught TypeError: Cannot read properties of undefined (reading ‘a’)
While working with Angular applications, you may find yourself in a position where your development build is successful with ng serve
command, application works fine in browser. However, as soon as you create a production build with command ng build -c production
you start getting the Uncaught TypeError: Cannot read properties of undefined (reading 'a')
where a
could be any other property name or object. The console errors will show the compiled JavaScript file with error line number, which are obscured.
So the question is, how to find the actual issue? If you put the exact error in internet search, you will be getting different types of solutions as the error can be from various reason and most of the time different from your project.
One of the solution you can try is to set the sourceMap
property to true
of production
object (NOT `build`) in angular.json
and run ng serve -c production
command to keep watching errors while running application in production mode.