24

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>
4
  • 1
    Please share the content of Features.vue? Commented Aug 27, 2022 at 17:04
  • @BoussadjraBrahim, it's just a div with script setup and inside it is an import of a component Commented Aug 27, 2022 at 17:16
  • so where is said setup in your code? Commented Aug 27, 2022 at 17:43
  • Oh, well I didn't notice it ;-; Commented Aug 27, 2022 at 17:45

5 Answers 5

43

A @Boussadjra mentioned this could happen in Visual Studio Code if Vetur extension is installed there. Insetted of Vetur if we install Volar extension in Visual Studio Code this problem gets solved.

Sign up to request clarification or add additional context in comments.

2 Comments

This issue is addressed in the vue 3 documentation, vuejs.org/guide/typescript/overview.html#volar-takeover-mode.
Adding to this answer, they have now marked Volar as deprecated and recommend to use Vue - Official extension instead (marketplace.visualstudio.com/items?itemName=Vue.volar)
21

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)

5 Comments

I'm using Vue 3 with vite and I'm thinking something is wrong with Vetur, because my code has setup as you said and it keep saying no export default in module
@Shad, you should disable vetur extension and use Volar instead of it
Volar extension is deprecated. Use the Vue - Official (Id: Vue.volar)
@mukolweke you're right
Such a rookie mistake, thank you!
8

Official Recommended Setup

Just disable Vetur Ext and install Vue - Official Ext

Comments

1

You must add export default in your component's script by example:

<script>
export default {
  name: "HelpView",
};
</script>

Comments

1

I use vue3 and got the same problem. Sloved through disabled vutur Ext in VScode And recommand install this extension https://marketplace.visualstudio.com/items?itemName=Vue.volar vue-official

1 Comment

Hey, it looks like this is basically a duplicate of an earlier answer stackoverflow.com/a/78586451/13762264

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.