title: Failed to load module script: The server responded with a non-JavaScript MIME type of ""
body: <p>I've this html page with a module ...</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;hello-world color="blue" /&gt;
          &lt;hello-world color="red" /&gt;
          &lt;hello-world /&gt;
          &lt;script type="module"&gt;
              import { HelloWorld } from './HelloWorld.js'
              window.customElements.define('hello-world', HelloWorld)
          &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>... and the module content is ...</p>
  
  <pre><code>export class HelloWorld extends HTMLElement {
      get color () {
          return this.getAttribute('color') || 'gray'
      }
  
      set color (value) {
          this.setAttribute('color', value)
      }
  
      connectedCallback() {
          window.requestAnimationFrame(() =&gt; {
              const div = document.createElement('div')
              div.textContent = 'Hello World!!!'
              div.style.color = this.color
              this.appendChild(div)
          });
      }
  }
  </code></pre>
  
  <p>I run a PHP server using <code>php -S localhost:8888 -t .</code> and all works fine:</p>
  
  <p><a href="https://i.stack.imgur.com/nhuoi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nhuoi.png" alt="enter image description here"></a></p>
  
  <p>Instead, ... if I move module in <code>./main.mjs</code> file with content ...</p>
  
  <pre><code>import { HelloWorld } from './HelloWorld.js'
  window.customElements.define('hello-world', HelloWorld)
  </code></pre>
  
  <p>... changing the html part in ...</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;hello-world color="blue" /&gt;
          &lt;hello-world color="red" /&gt;
          &lt;hello-world /&gt;
          &lt;script type="module" src="main.mjs"&gt;&lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>... I get the following error:</p>
  
  <blockquote>
    <p>Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.</p>
  </blockquote>
  
  <p>Why? May I fix it? How?</p>