laravel_blog_image

Laravel Mix & Vue : Module parse failed: Unexpected token

I was trying to use Vue with Laravel 8 while running running npm run dev, encountered following error.ย 

package.json
 "laravel-mix": "^6.0.10",
 "vue-loader": "^15.9.6",
 "vue-template-compiler": "^2.6.12",
 "vue": "^2.6.12"

To resolve this issue, I updated webpack.mix.js & app.js with following.

webpack.mix.js
mix.js('resources/js/app.js', 'public/js').vue({ version: 2 });
app.js
window.Vue = require('vue').default;

These changes should resolve the problem.

Author: Danyal
I'm a skilled programmer specializing in Vue.js/Nuxt.js for front-end development and PHP Laravel for back-end solutions. I have a strong focus on API design and development, complemented by experience in web server setup and maintenance. My versatile expertise ensures seamless creation and maintenance of web applications, covering everything from intuitive user interfaces to robust server-side functionality. Passionate about coding and driven by a lifelong learning mindset, I invite you to explore more at danyal.dk.