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

140
Views
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
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!