Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

498
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda