Laravel Mix & Vue : Module parse failed: Unexpected token
See original GitHub issueHi I want to use Vue 2 with laravel mix 6 but it didn’t work it display this error message :
Module parse failed: Unexpected token
webpack.mix.js
const mix = require(‘laravel-mix’);
mix.js('resources/js/app.js', 'js')
.vue({ version: 2 })
.setPublicPath('public');
if (mix.inProduction()) {
mix.version();
}
package.json
"devDependencies": {
......
"laravel-mix": "^6.0.6",
"vue": "^2.6.12",
"vue-loader": "^15.9.6",
"vue-template-compiler": "^2.6.12"
}
resources/js/app.js
require('./bootstrap');
import Vue from 'vue';
import App from './components/App.vue';
new Vue({
el: '#app',
components: { App }
});
resources/js/components/App.vue
<template>
<div class="alert" v-text="message"></div>
</template>
<script>
export default {
data() {
return {
message: 'I am an alert.'
};
}
};
</script>
<style>
</style
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:19
Top Results From Across the Web
Laravel Mix & Vue : Module parse failed: Unexpected token
Hi I want to use Vue 2 with laravel mix 6 but it didn't work it display this error message : Module parse...
Read more >Laravel Mix & Vue : Module parse failed ... - Laracasts
Hi I want to use Vue 2 with laravel mix 6 but it didn't work it display this error message : Module parse...
Read more >Laravel Mix Module parse failed: Unexpected token (18:20)
My problem solved. In my case, original error comes from vue part. In vue router index.js file there was 'import { vue }...
Read more >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 ...
Read more >Now I got the below error while using Vue in the laravel ...
Now I got the below error while using Vue in the laravel project. Uncaught Error: Module parse failed: Unexpected token (1:0)
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just add
.vue({ version: 2 })
in webpack.mix.jsmix.js('resources/js/app.js', 'public/js').vue({ version: 2 });
I had similar problems upgrading Laravel-Mix.
package.json
webpack.mix.js
app.js
For me the information from this answer https://github.com/JeffreyWay/laravel-mix/issues/2747#issuecomment-755483920 fixed my problem
Also the upgrade guide had some useful information - https://github.com/JeffreyWay/laravel-mix/blob/master/UPGRADE.md
Hope this might help :bowtie: