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

143
Visualizações
Importing image to an object through Javascript results in an error

I am following this youtube-tutorial to make my first html5-canvas game: https://www.youtube.com/watch?v=4q2vvZn5aoo&t=5133s. At 59:10 he says you can use vs code to fix my problem, but he doesn't say how, and then proceeds to show how it's done on a mac. Here is my question:

When i import an image using this line of code in the Javascript-document: import platform from "./Canvasgame.img/platform.png" ("platform" is the object i want to add the image to), it gives me this error: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "image/png". Strict MIME type checking is enforced for module scripts per HTML spec.

I use the live-server extension on vs code, and i link to the javascript-document as a module-type: <script src="Canvasgame.js" type="module"></script>. I don't understand why it doesn't let me import the image.

about 4 years ago · Juan Pablo Isaza
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