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

如何解决Laravel/Vue项目中npm run watch命令的报错问题?

Fixing "Module not found: Can't resolve './App.vue'" in Laravel/Vue

Hey there, let's work through this error together—since you're new to Laravel/Vue, this kind of file path issue is super common, so no need to stress!

What's the core problem?

The error means Webpack (which Laravel Mix uses under the hood) can't find the App.vue file you're trying to import in app.js. Let's go through the most likely fixes step by step.


Step 1: Verify the App.vue file exists in the right place

First, double-check your project's resources/js directory. You need to have a file named App.vue exactly at this path:
C:\Users\kodione\laravel-vue-exercise\resources\js\App.vue

If the file doesn't exist, create it with a basic template (this is the standard structure for your root Vue component):

<template>
  <div id="app">
    <!-- Your app content will render here via router-view -->
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: 'App'
}
</script>

<style scoped>
/* Add global or component-specific styles here */
</style>

Step 2: Check for filename case sensitivity

Even though Windows doesn't care about uppercase/lowercase filenames, Webpack's module resolver can be strict. Make sure:

  • The file is named App.vue (not app.vue, APP.vue, or any other variation)
  • The import line in app.js matches exactly: import App from './App.vue';

Step 3: Clear cache and recompile

Sometimes old build cache can cause weird missing file errors. Try these commands to reset things:

# First, clean existing compiled assets
npm run clean

# Then restart the watch command
npm run watch

If your Laravel Mix setup doesn't have a clean command, just delete the public/js directory manually, then run npm run watch again.

Step 4: Confirm your directory structure matches expectations

Your core frontend files should be arranged like this (simplified):

laravel-vue-exercise/
├── resources/
│   └── js/
│       ├── app.js       # Your main JS entry point
│       ├── App.vue      # Root Vue component (what you're importing)
│       └── routes.js    # Your router config file
└── ...

If App.vue is in a subfolder (like resources/js/components/App.vue), you'll need to update the import path in app.js to match:

import App from './components/App.vue';

Quick tip for new Laravel/Vue devs

When using ./ in an import path, it always refers to the current directory of the file you're writing in. So since app.js is in resources/js, ./App.vue looks directly in that same folder.

内容的提问来源于stack exchange,提问作者Michał Rogal

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.29 09:43:12