I am working on my first Vue 3 project after using Vue 2 for a long time.
Normally in my components on Vue 2 projects I can import a library, for example moment, like so:
<script>
const moment = require("moment")
export default {
...
</script>
In vue 3, I'm trying to do the same:
<script setup>
const moment = require("moment")
</script>
However I get the error
Uncaught ReferenceError: require is not defined
How can I get around this and import modules into a vue3 component?
You can not use require in Vite, did you try with import:
<script setup>
import moment from 'moment'