kylemabaso's avatar

Uncaught TypeError: Vue.component is not a function

Hi Guys,

I'm getting an error that says "app.js:28217 Uncaught TypeError: Vue.component is not a function at ./resources/js/app.js"

require('./bootstrap');

window.Vue = require('vue').default;

Vue.component('video-chat', require('./components/VideoChat.vue').default);

I've tried using import instead of window.Vue. Event tried window.Vue without the default.

0 likes
6 replies
Sinnbeck's avatar

Are you using vite or mix for compiling?

MohamedTammam's avatar

Use

require('./bootstrap');
import VideoChat from './components/VideoChat.vue';

window.Vue = require('vue').default;

Vue.component('video-chat', VideoChat);
kylemabaso's avatar

@MohamedTammam With this recommendation, I get app.js:25067 Uncaught TypeError: Cannot read properties of undefined (reading 'component')

MohamedTammam's avatar

Use

require('./bootstrap');
import Vue from 'vue';
import VideoChat from './components/VideoChat.vue';

Vue.component('video-chat', VideoChat);
rodrigo.pedra's avatar

Does your package.json is importing Vue 2 or Vue 3?

Vue.component() does not exist on Vue 3.

In Vue 3 you can still register a global components, but it is not a global method anymore in the Vue object.

You need to first call createApp() and the app instance will provide a component method to register global components.

https://vuejs.org/api/application.html#app-component

Please or to participate in this conversation.