title: Uncaught SyntaxError: Cannot use import statement outside a module for sample file
body: <p>I have a folder for test only that contain only 3 file</p>
  <ul>
  <li>index.js</li>
  <li>sample.js</li>
  <li>index.html</li>
  </ul>
  <p><strong>Index.html</strong></p>
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  
  &lt;head&gt;
  
      &lt;script src=&quot;index.js&quot;&gt;&lt;/script&gt;
      &lt;title&gt;Page Title&lt;/title&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
  
      &lt;h1&gt;This is a Heading&lt;/h1&gt;
      &lt;p&gt;This is a paragraph.&lt;/p&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  <p><strong>index.js</strong></p>
  <pre><code>import { data } from './sample';
  console.log(data)
  const newObj = Object.entries(sampleOb).filter((item, index) =&gt; index === 0)
  console.log(Object.fromEntries(newObj) )
  </code></pre>
  <p>sample.js</p>
  <pre><code>export const data = {
      name:&quot;abc&quot;,
      age:&quot;19&quot;
  }
  </code></pre>
  <p>But problem is when i try to import data.js to index.js, it show this error
  <a href="https://i.stack.imgur.com/lfmZF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lfmZF.png" alt="enter image description here" /></a>
  So how to fix this, thank you</p>