question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot start index.html with `script type="module"`

See original GitHub issue

Describe 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:

  1. build vue.js app using vite
  2. swa start ./dist (using 0.1.1-alpha swa cli)
  3. 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:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
manekinekkocommented, Mar 16, 2021

That’s awesome! Let’s know how it went ☺️

Good luck!

0reactions
k-miyakecommented, Mar 16, 2021

@manekinekko I updated the SWA CLI to 0.2.0 -> 0.2.1-alpha and Vite to 2.0.5 -> 2.1.0 and it worked! Thanks for the quick response! I’ll demo it at Azure local event next week!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found