Cannot start index.html with `script type="module"`
See original GitHub issueDescribe the bug
Using the 0.1.1-alpha
SWA CLI,
<script type="module" ... >
with js files loaded in index.html
with SWA CLI, the following execution error occurs.
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.
To Reproduce Steps to reproduce the behavior:
- build vue.js app using vite
- swa start ./dist (using
0.1.1-alpha
swa cli) - Index.html is not rendered and the following error is displayed in the browser console
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.
Expected behavior index.html will be rendered
Desktop (please complete the following information):
- OS: macOS 11.2.3
- Browser: Chrome
- Version: 89.0.4389.82
Additional context The application that is built by vite using esbuild, so that may be the cause.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Javascript import module to index.html not running due to errors
Using import requires the script to be of type module not just the imported script. You should place modules imports in <head> (at...
Read more >Why can't I import a javascript module in an HTML file?
Solution 1 · 1) In Teacher.js-. Javascript. import { Person } from "./Person.js"; · 2) In Index.js-. Javascript. import { Teacher } from...
Read more >JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >HTML - Parcel
The type="module" attribute should be used to indicate that a file is an ES module or CommonJS file. If it is omitted, then...
Read more >How to Include three.js in Your Projects
Take special notice of type="module" , which we're using to tell the browser the linked file is a JavaScript module. If anything in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s awesome! Let’s know how it went ☺️
Good luck!
@manekinekko I updated the SWA CLI to
0.2.0
->0.2.1-alpha
and Vite to2.0.5
->2.1.0
and it worked! Thanks for the quick response! I’ll demo it at Azure local event next week!