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

289
Visualizações
Got this error after refreshing page in ReactJS app: Uncaught SyntaxError: Unexpected token '<'

I keep getting this error Uncaught SyntaxError: Unexpected token '<' after I refresh the page. The error comes from a top level component called <Navbar /> which I added in App.js. The issue is not present in any other component and there is also no error when I navigate to the page from another page. Only when I refresh the page

I think it assumes the the html page index.html in the public folder is a js file.

enter image description here

How do I fix this any why does it only occur on certain pages.

Pages that work well:

<Route path="/" element={<div><br /> <br /> Hello</div>} />
<Route path="/newcollection" element={<NewCollection />} />

Pages that don't work well:

<Route path="/:contractAddress/:metaDataHash/:ownerAddress/mint" element={<NewNFT />} />

More relevant info:

enter image description here

I have a strong feeling that it has to do with the way I imported JS here. As shown in the error message. enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I was able to arrive to this answer thanks to the comments especially @DrewReese.

The issue was with how I located the js and css files in the index.html page. For some reason react was able to locate the files with out / prepend to source location. SO, I basically solved all the problems by adding / ahead of all source in the index.html folder. And now it looks like this:

<script src="/js/modernizr-3.8.0.min.js"></script>

instead of this:

<script src="js/modernizr-3.8.0.min.js"></script>
about 4 years ago · Juan Pablo Isaza Relatório

0

Since jQuery is required by some libraries, you would do well to move the script tag with the src of jQuery above all other script tags. modernizr is above jQuery in your image. If the issue still reproduces, then click on the error in your dev tools and see which line is throwing it and which file the line is located at. Make sure that before that file is loaded, jQuery is already loaded.

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