[Vuejs]-`Cannot read properties of undefined (reading 'component')`

0๐Ÿ‘

I also faced this issue. However I managed to resolve this, thus Iโ€™m sharing my answer.

Using Vue3 than make the necessary changes in your app.js:

import {
  createApp
} from 'vue';
const app = createApp({});

// You can register your components globally like this also
// Add as many components as you want.

app.component('Name of your component', require('Path to the component').default)

// In your case 
app.component('my-button',require('Path to the component').default);

app.mount('#app');

I think it should solve the issue.
Please check.

-1๐Ÿ‘

i stumbled

const app = createApp ({}) 

should come before

components.forEach (component => {
    app.component (component.name, component)
})

Leave a comment