laravel 无法运行npm运行dev

ni65a41a  于 2022-12-19  发布在  其他
关注(0)|答案(1)|浏览(138)

我跑完之后

php artisan ui vue --auth,

我正在做npm安装没有问题,但当我运行npm run dev时,它显示如下错误

ERROR in ./resources/js/components/ExampleComponent.vue 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <template>
|     <div class="container">
|         <div class="row justify-content-center">

webpack compiled with 1 error

如何解决这个问题?

zyfwsgd6

zyfwsgd61#

laravel mix documentation中所述,为了使用Vue js,必须在webpack.mix.js文件(在项目的根文件夹中)中使用mix.vue()命令。
例如:

mix.js('resources/js/app.js', 'public/js').vue()
.sass("resources/scss/app.scss", "public/css");

而不是这样:

mix.js('resources/js/app.js', 'public/js')
.sass("resources/scss/app.scss", "public/css");

相关问题