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

Laravel集成Vue Router后执行npm run watch报错及Vue DevTools无法检测Vue的问题求助

Fixing the npm run watch Compile Error When Integrating Vue Router with Laravel

Alright, let's break down what's going wrong here and get it fixed step by step:

First, the Root Issue

Looking at your error message and code snippets, the most immediate problem is a case mismatch in your Vue component file extension, and we’ll also double-check your webpack configuration to make sure it’s set up to handle Vue files correctly.

Step 1: Fix the Component File Extension Case

Take a close look at your imports:

  • In app.js, you’re referencing ExampleComponent.vue (lowercase .vue extension)
  • But in routes.js, you’ve written ExampleComponent.Vue (uppercase .Vue extension)

Most operating systems (like Linux or macOS) are case-sensitive when it comes to file names—webpack sees these as two completely different files, so it can’t find the correct one to parse. Here’s what to do:

  • Confirm your actual component file uses a lowercase .vue extension
  • Update the import in routes.js to match exactly:
import ExampleComponent from "./components/ExampleComponent.vue";

Step 2: Verify Laravel Mix Vue Configuration

Laravel’s default Mix setup supports Vue files out of the box, but if you’ve modified your webpack.mix.js file, you need to ensure it enables Vue processing. Your config should look at least like this:

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

mix.js('resources/js/app.js', 'public/js')
   .vue(); // This line is critical—it enables compilation for .vue files

If you were missing the .vue() call, add it, then restart your npm run watch process.

Step 3: Clear Cache and Recompile from Scratch

Sometimes cached files can cause strange, hard-to-track issues. Let’s do a clean install and build:

rm -rf node_modules
rm package-lock.json
npm install
npm run watch

Why Vue DevTools Stopped Working

This is just a side effect of the compile error—since your app.js wasn’t built successfully, the Vue instance never loads in the browser. Once you fix the compilation issues and refresh the page, DevTools should detect Vue again like it did before.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 13:02:44