ES6 Code in an Angular Project
Written by Preston Lamb
Posted on Aug 15, 2018
const) and a
The issue came a few days ago when I attempted to do a production build when we were going to deploy the application. I ran the
ng build --prod command, and about halfway through I got an error:
Sometimes I'd get this error, and sometimes it was different but similar. The error was something about "unexpected token const". It wasn't real specific though, and I had no idea what file to even look in to figure out what the issue was. So I just started googling the issue, and was lucky enough to come across this GitHub issue that pointed me in the right direction. Specifically, I found this comment:
At that point I was able to go back into my codebase and figure out what the issue was. Because the file was small enough, I was able to manually change it back to ES5 syntax. After doing that, the build succeeded and I could move on.