module type is not detectable on a nodejs project with vanillajs configured

I created for this project, a nodejs server configured to accept javascript as es6 modules.

That doesn’t matter.

Your error message is client side.

You have two different JS programs. One running through Node.js (which creates a web server) and one running in the browser.

The error message is from the latter.


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

So let’s trace this:

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

The browser is asking for http://localhost:3333/index.js and getting an HTML document. That isn’t a JS file, so it errors.

Likely you don’t have an index.js file in the express folder where you told Express to look for static files.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top