Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

491
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda