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

496
Views
Al compilar Angular en modo de producción, se obtienen errores Uncaught SyntaxError: Token inesperado '<'

Hola, recibo este error en el navegador de la consola en mi aplicación angular 8, veo las ventanas del navegador en blanco y aparece este error

 Uncaught SyntaxError: Unexpected token '<'

ingrese la descripción de la imagen aquí

intento ejecutar mi compilación ng

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

nada funciona...

mi archivo de configuración de apache

 <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>

como se soluciona esto?

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

0

Como dijo @MikeOne en los comentarios anteriores...

Probablemente también esté devolviendo el index.html en las solicitudes de JavaScript.

debido a su configuración de Apache ...

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

Esto literalmente reescribe todo (no solo "todo lo demás") en index.html . Por lo tanto, al solicitar anything.js cosa.js, el servidor responde con index.html . Entonces, sí, el navegador está tratando de analizar index.html como JavaScript.

Su configuración de Apache debería ser algo como esto, para evitar que las solicitudes de recursos estáticos se reescriban en index.html :

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

O, un poco menos eficiente (pero posiblemente más 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!