Using Vue.js 3 CDN – Uncaught SyntaxError: Cannot use import statement outside a module

I’m using a CDN to play around with Vue 3.

From my index.html, I’m importing my app.js file like this –

<script src="app.js"></script>

The app.js file contains this code –

import createApp  from 'vue'
import Root from './App.vue'

createApp(Root)
    .mount('#app')

I can eliminate this error by adding type="module" to the script tag which will then give me another error involving a MIME type –

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.

Why is this happening and how can I fix this?