Laravel-mix: Uncaught TypeError: Vue.component is not a function

Created on 6 Jan 2021  路  2Comments  路  Source: JeffreyWay/laravel-mix

  • Laravel Mix Version: 6.0.6 (npm list --depth=0)
  • Node Version (node -v): v12.18.2
  • NPM Version (npm -v): 6.14.6
  • OS: Win10

Description:

Unable to get vue to work. Throwing Uncaught TypeError: Vue.component is not a function

Steps To Reproduce:

  1. Fresh install laravel 8
  2. Add laravel/ui
  3. Run php artisan ui vue --auth
  4. Add .vue() in webpack.mix,js
  5. Run npm run dev
  6. Load the site and look at the console logs.

Most helpful comment

It's because we're using the esm build of Vue. The laravel/ui package needs an update to either import Vue as an ES6 module, or to add .default after the require.

For your issue, use this in resources/js/app.js:

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

All 2 comments

It's because we're using the esm build of Vue. The laravel/ui package needs an update to either import Vue as an ES6 module, or to add .default after the require.

For your issue, use this in resources/js/app.js:

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

Perhaps this can be mentioned in the upgrade guide

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amin101 picture amin101  路  3Comments

rderimay picture rderimay  路  3Comments

hasnatbabur picture hasnatbabur  路  3Comments

jpriceonline picture jpriceonline  路  3Comments

dtheb picture dtheb  路  3Comments