You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 7 React脚手架执行npm run dev时出现找不到vue-template-compiler模块错误

解决Laravel 7切换React脚手架时找不到vue-template-compiler的问题

问题原因

执行php artisan ui react --auth后,项目配置中可能残留了Vue相关的编译配置或依赖引用,导致npm编译时尝试加载Vue模板编译器。

解决方案

1. 修正webpack.mix.js配置

打开项目根目录下的webpack.mix.js,确保内容为React相关配置,移除所有Vue相关代码:

const mix = require('laravel-mix');

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

确认文件中没有mix.vue()这类Vue编译语句。

2. 清理依赖并重新安装

执行以下命令彻底清理旧依赖并重新安装:

rm -rf node_modules package-lock.json
npm install

3. 检查并清理package.json

打开package.json,确认dependencies和devDependencies中没有vue、vue-template-compiler这类Vue相关依赖,若存在则手动删除,之后再次执行npm install。

4. 清除npm缓存(可选)

若上述步骤无效,尝试清除npm缓存后重新安装:

npm cache clean --force
npm install && npm run dev

内容的提问来源于stack exchange,提问作者xrak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 00:15:39