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

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