Failed to load module script: The server responded with a non-JavaScript MIME type of "text/plain". Strict MIME type checking is enforced for module scripts per HTML spec.
I get this error in chrome after trying to add this line to my HTML code:
<script type="module">import * as hello from './__target__/hello.js'; window.hello = hello;</script>
<!-- From the official documentation of Transcrypt -->
I've been trying to fix for hours, someone suggested to change the type to text/javascript and to use the src tag (src = './__ target__/hello.js') but I need some imports in hello.js
FIXED: Ok I was starting the server with 'python -m http.server' from command line, I just replaced it with this python2 script:
#Use to create local host
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
Handler.extensions_map.update({
".js": "application/javascript",
});
httpd = SocketServer.TCPServer(("", PORT), Handler)
print ("Serving at port", PORT)
print(Handler.extensions_map[".js"])
httpd.serve_forever()
<script src="..." type="module"></script>
. If that yields the same error, your server is not sending files with their correct mime-type, and you should fix that (almost every server can do this for you out-of-the-box, so just google for how to configure yours to correctly add the mime type header) – Mike 'Pomax' Kamermans