Uncaught TypeError: Vue.component is not a function
For any one who has the same issue and is not related to Laravel.
Hint: using Vue 3+
Register the component globally:
const MyComponent = {
// ... options ...
}
// if you do not have App component
Vue.createApp({}).component("my-component", MyComponent).mount("#app");
// if you have an App component
const App = {
// ... options ...
}
const app = Vue.createApp(App);
app.component("my-component", MyComponent);
app.mount("#app");
Please refer to Documentation for more info
import vue properly in your code using import keyword like this:
//import vue
import Vue from 'vue';
//register component
Vue.component('yourComponentName',require('./components/yourComponentName.vue').default);
//initialize vue
const app = new Vue({
el: '#app',
});
After an update from laravel-mix 5.0.9
to laravel-mix 6.0.11
on a laravel 7 project it started to see this error on vue compiled views. I change the call the Vue package:
Use
import Vue from 'vue'
instead ofwindow.Vue = require("vue");
worked for me.