Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

497
Views
Compiling Angular in production mode get errors Uncaught SyntaxError: Unexpected token '<'

Hello i get this errors in console browser in my angular 8 app, i see the browser windows blank and i get this error

Uncaught SyntaxError: Unexpected token '<'

enter image description here

i try run my ng build

ng build --base-href / --aot --prod
ng build --base-href /my_app/ --aot --prod
ng build --prod
ng build --aot --prod --output-hashing none

nothing works...

my apache config file

<VirtualHost *:80>
        DocumentRoot "/var/www/html/MrpProy/my_app/dist/my_app/"
        ServerName mydomain.com
        <Directory /var/www/html/MrpProy/my_app/dist/my_app/>
            RewriteEngine on
            # Rewrite everything else to index.html to allow HTML5 state links
            RewriteRule ^ index.html [L]
        </Directory>
    </VirtualHost>

how this solve?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

As @MikeOne stated in comments earlier...

You’re probably returning the index.html on the javascript requests as well..

because of your Apache config...

# Rewrite everything else to index.html to allow HTML5 state links
RewriteRule ^ index.html [L]

This literally rewrites everything (not just "everything else") to index.html. So, when requesting anything.js, the server is responding with index.html. So, yes, the browser is trying to parse index.html as JavaScript.

Your Apache config should be something like this instead, in order to prevent requests for static resources being rewritten to index.html:

RewriteEngine on

# Rewrite everything that does not look-like a file to index.html
RewriteRule !\.\w{2,4}$ index.html [L]

Or, slightly less efficient (but possibly more flexible):

# Rewrite everything that is not a file to index.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [L]
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!