Search code examples
typescriptvue.jsvuejs3vue-composition-apivue-script-setup

Vue | Module has no default export


I'm facing an error with vue3, ts, vue cli where it says Module '"c:/Users/USER/Documents/top-secret-project/src/components/Features/Features.vue"' has no default export. when importing a component from a file I have no idea why did this specific component decide to now work.

here's Features.vue

<script lang="ts">
import Feature from "./Feature.vue";
</script>

<template>
  <Feature />
</template>

Solution

  • With script setup syntax there's no need to add export default in your script, just add the setup attribute to your script:

    <script lang="ts" setup>
    import Feature from "./Feature.vue";
    </script>
    
    <template>
      <Feature />
    </template>
    

    You should disable Vetur extension and use Vue - official (ex Volar)