title: Javascript import module to index.html not running due to errors
body: <p>I am trying to import a module to my index.html file.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>// Index.html:
  
  &lt;!doctype html&gt;
  
  &lt;html lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
  
    &lt;title&gt;&lt;/title&gt;
  
  &lt;/head&gt;
  
  &lt;body&gt;
  
  &lt;div&gt;&lt;/div&gt;
  
    &lt;script type="module" src="module.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
  
      import { addTextToBody } from 'module.js';
  
      addTextToBody('some text here');
  
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And the js:</p>
  
  <pre><code>export function addTextToBody(text) {
  
    const div = document.createElement('div');
    div.textContent = text;
    document.body.appendChild(div);
  
  }
  </code></pre>
  
  <p>I am getting these errors:</p>
  
  <p>Uncaught SyntaxError: Unexpected token { - Line 18</p>
  
  <p>Access to Script at 'module.js' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.</p>
  
  <p>How can I fix this?</p>