[Vuejs]-TypeError: Vue.component is not a function laravel project

0👍

I was making some dependecies updates on a laravel 7 project and it started to see this error on vue compiled views. I change the Vue package call:

Use import Vue from 'vue' instead of window.Vue = require("vue"); worked for me.

0👍

I am new to Vue.js so I will share how I got my app running. I am using Laravel 9 and Vue 3. My code was as follows:

// import Vue from 'vue';
import {
    createApp
} from 'vue';

const app = createApp({});

Vue.component('mainapp', require('./components/mainapp.vue').default)

app.mount('#app');

This gave the following error:

Cannot read properties of undefined (reading ‘component’)

So, I did a console.log(Vue) and I got undefined. I then changed to

app.component('mainapp', require('./components/mainapp.vue').default)

and it worked!

Leave a comment