Resolve! Uncaught SyntaxError: Unexpected token ‘,’ or ‘<' in Angular

To create a production build for a remote server I usually run following ng command:

$ ng build --prod 

But at the client end, there was some stage error popping up in the console and the application was not loading. Surprisingly it was working fine on my end and on my mobile network as well.

The error was something like this:

Error Uncaught SyntaxError: Unexpected token ‘,’

and sometimes this:

Error Uncaught SyntaxError: Unexpected token ‘<‘

I tried to create the production again and again but the same thing was happening…


Then After reading some forums, I got to know, it is something related to Hashing added to the map file during production build.

So I ran this which resolved this issue:

$ ng build --aot --prod --output-hashing none

After that, it created the bundle without any Hashing using Ahead Of Time compilation which resolved this issue at all places.

Hope this can help somebody 🙂

Leave a Comment

Your email address will not be published. Required fields are marked *