Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

successdav's avatar

Uncaught TypeError: Vue.component is not a function

Uncaught TypeError: Vue.component is not a function . The error is generated in the following line of code

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

I am importing Vue on bootstrap.js

window.Vue = require('vue');

I get this error on my console after upgrading the following packages

Old Version Left | New Version Right

"axios": "^0.19.2", 			=> "axios": "^0.21.1",
"resolve-url-loader": "^2.3.1", 	=>"resolve-url-loader": "^3.1.2",
"laravel-mix": "^4.0.7",		=> "laravel-mix": "^6.0.0-beta.17"

after upgrading the Laravel mix the following dependencies were installed "vue-loader": "^15.9.5",

0 likes
5 replies
williams's avatar

After upgrading to laravel-mix 6, I get this same error with the laravel-provided example vue app.

laravel-mix 5 works fine with the same app.

1 like
successdav's avatar
successdav
OP
Best Answer
Level 4

Hi, I got to fix the error, maybe you're having the same configuration problem as I did. Here is a solution to try.

These line of code should go directly at the top of your app.js

import Vue from 'vue'
window.Vue = Vue;
require('./bootstrap'); 

then followed by your components and then create your vue instance

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

const app = new Vue({
    el: '#app',

    router
}); 

I had the error because the import Vue from 'vue' statement was included in my bootstrap.js and moving it to app.js fixed it. I went ahead to try it on a new laravel project by importing vue in my bootstrap file and then requiring it at the top of app.js and I got the error, I then import vue right there in my app.js followed by the require statement as seen above and the error disappear.

6 likes
josegus's avatar

@successdav I have the same error, but I don't want to declare my vue components manually, I want to make it automatically usiing:

const files = require.context('./', true, /.vue$/i) files.keys().map(key => Vue.component(key.split('/').pop().split('.')[0], files(key).default))

apgoswami's avatar

TypeError: components_students_StudentFormComponent_vue__WEBPACK_IMPORTED_MODULE_1_.default.use is not a function

Please or to participate in this conversation.