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

Laravel 9注册/登录视图加载失败:Vite清单文件缺失问题

解决Laravel 9中Vite Manifest Not Found错误

1. 确认Vite构建产物状态

  • 开发环境下,若运行npm run dev,需通过Vite热重载服务的代理访问项目(比如访问Laravel默认的http://localhost:8000),不能直接打开静态文件或绕过Vite服务。
  • 生产/本地测试需要生成静态资源时,执行npm run build,这会在public/build目录下生成manifest.json及对应静态文件。

2. 检查环境配置

打开项目根目录的.env文件,确保APP_URL配置正确:

  • 开发环境设为http://localhost:8000(与Laravel artisan serve端口一致)
  • 生产环境需与部署域名一致,且必须先执行npm run build生成资源文件

3. 修正Vite配置文件

检查vite.config.js,确保资源入口路径与@vite指令匹配:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import vue from '@vitejs/plugin-vue';

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/sass/app.scss',
                'resources/js/app.js',
            ],
            refresh: true,
        }),
        vue({
            template: {
                transformAssetUrls: {
                    base: null,
                    includeAbsolute: false,
                },
            },
        }),
    ],
});

确认input数组内的路径和app.blade.php中@vite指令的路径完全一致,无拼写错误。

4. 清理缓存并重新构建

执行以下命令重置环境:

# 清除Laravel缓存
php artisan cache:clear
php artisan route:clear

# 重置前端依赖与构建
rm -rf node_modules
rm package-lock.json
npm install
npm run build

5. 验证资源文件存在性

检查resources/sass/app.scss和resources/js/app.js是否存在于项目中,若php artisan ui vue --auth生成时文件被误删或移动,需恢复或调整@vite指令中的路径。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 04:46:02