Fix 'Cannot read properties of undefined (reading 'render')' in Vue component
This error means Vue can't find a render function in your component. It's almost always a broken import or a missing default export.
Quick answer
Check your component import: you're likely importing a default export that doesn't exist. Replace import Foo from './Foo.vue' with import Foo from './Foo.vue'; console.log(Foo) — if it logs undefined, the import path is wrong or the component file has no default export.
Why this happens
Vue components have a render function — either written directly in the Options API or generated by the template compiler. When Vue tries to mount a component and calls .render() on undefined, it means the component object itself is null or undefined. This isn't a runtime error in the component's logic; it's a load-time failure. The most common trigger: you moved a component file or renamed it but forgot to update the import — or you're using an async component pattern incorrectly, like defineAsyncComponent(() => import('./Foo.vue')) with a typo in the path. In Vue 3 with <script setup>, if you accidentally have export default {} after the setup block, it can override the generated render. In Vue 2, it's almost always a missing default export — you wrote export const Foo = { ... } instead of export default { ... }.
Fix steps
- Inspect the import. Open the file where the error occurs (the parent that mounts the broken component). Add a console log right after the import:
Ifimport MyComponent from './components/MyComponent.vue';
console.log('MyComponent:', MyComponent);MyComponentisundefined, the import path is wrong or the file doesn't exist. Fix the path. - Check the component file's export. Open the component file itself (e.g.,
MyComponent.vue). Ensure it has exactly one default export. In Vue 3<script setup>, you don't needexport defaultat all — the compiler adds it. If you have both<script setup>and a separate<script>withexport default, remove the duplicate. In Vue 2 or Options API, make sure you haveexport default { name: 'MyComponent', ... }— notexport constormodule.exports. - Remove the component from the template entirely. Temporarily comment out
<MyComponent />in the parent. If the error disappears, you've confirmed the component itself is the problem. Re-add it and proceed to step 4. - Try a minimal inline component for testing. Replace the import with a local definition:
If this works, your component file is corrupted or has syntax errors. Rebuild it from scratch — copy the template and script sections into a new file.import { h } from 'vue';
const MyComponent = { render() { return h('div', 'test') } }; - Check for circular dependencies. If component A imports B, and B imports A (directly or through a chain), Vue can get a
undefinedcomponent at mount time. Break the cycle: usedefineAsyncComponentfor one of the two, or restructure so the dependency is one-way.
Alternative fixes
- For async components: If you're using
defineAsyncComponent, the error might come from the loader function itself failing. Wrap the import in a try-catch:
This won't fix the root cause, but it gives you a fallback UI instead of a crash.defineAsyncComponent(() => {
return new Promise((resolve) => {
import('./MyComponent.vue').then(resolve).catch(() => resolve({ template: '<div>Error loading</div>' }));
});
}); - Vue 2 + Webpack code splitting: If you're using dynamic imports with
require.ensureorimport()insidecomponents: { Foo: () => import('./Foo.vue') }, the chunk might fail to load. Check the Network tab — if the chunk returns a 404, fix the path. - TypeScript users: If you have a
.vuefile with<script lang="ts">and you're exportingdefaultas an interface or type instead of an object, Vue's runtime will getundefined. Addexport default defineComponent({ ... })to make the type explicit.
Prevention tip
Use a linter rule that catches missing default exports. In ESLint, enable import/default and import/named. It'll flag export const Foo in a .vue file as an error when you try to import it as default. Also, never rename or move component files without using your IDE's refactor feature (F2 in VS Code) — it updates all imports automatically. Manually editing import paths is where 90% of these errors start.
Was this solution helpful?