Property does not exist on type '{}'
I have these errors in my template on all my components even though the variables exist

2 Replies
Hi @Snoozie. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error "Property does not exist on type '{}'" in your Nuxt (Vue) templates usually means that the template is trying to access a property that TypeScript (or the template compiler) cannot find on the component's instance. This often happens when:
1. Props or Data are not properly defined or typed
For example, if you use a component and pass props like
In Nuxt 3/Vue 3, you should not use
If you are using TypeScript, make sure your
Sometimes, when using auto-imported composables or switching package managers, type-checking tools like
For example, if you use a component and pass props like
:title="post.title"
, but the child component does not declare title
as a prop, you'll get this error. Make sure to define all expected props in your component using the correct syntax. In Vue 3/Nuxt 3, you can use the defineComponent
helper or <script setup>
with defineProps
:
Or, with defineComponent
:
Nuxt problem Property was accessed during render but is not defined on instance
2. Accessing properties with this
in the templateIn Nuxt 3/Vue 3, you should not use
this
in the template. For example, use variables.appMenu
instead of this.variables.appMenu
in your template. Using this
will result in the property being undefined in the template context.
Nuxt 3 says "variables" is undefined while I have defined it within the data, how do I fix this?
3. TypeScript setup issuesIf you are using TypeScript, make sure your
<script>
tag has lang="ts"
. Otherwise, TypeScript types and intellisense will not work correctly, and you may see errors about missing properties.
Getting intellisense errors when declaring or using TS types/interfaces in Vue.js SFC files
4. Type-checking and auto-imported composablesSometimes, when using auto-imported composables or switching package managers, type-checking tools like
vue-tsc
may not recognize all auto-imported items, leading to similar errors. This can happen due to misconfiguration or issues with the type-checking setup.
Typecheck (vue-tsc) errors on all that is auto imported
Summary of what to check:
- Ensure all props used in templates are declared in the component.
- Do not use this
in templates.
- Use lang="ts"
in your <script>
tag if using TypeScript.
- If using auto-imports, ensure your type-checking setup is correct and up-to-date.
If you follow these steps and still see the error, please provide a code snippet for more specific help.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@414109446810370049> Kapa.ai is still learning and improving, please let me know how I did by reacting below.