0
votes

I was trying to import image using:

import image from 'image.jpeg';

the following error pops out.

Failed to load module script: The server responded with a non-JavaScript MIME type of "image/jpeg". Strict MIME type checking is enforced for module scripts per HTML spec.

in my index.html, I imported my main script file as:

<script src="index.js" type="module"></script>

then in the index.js:

import image from 'image.jpeg';

When I run it using Chrome, it results in the above-mentioned error. Any help?

1

1 Answers

0
votes

JavaScript running in a web browser can only import JavaScript modules.

There are tools (such as WebPack) which can import images, but you aren't using one of them.