Laravel

Fixing 'Vite manifest not found at: public/build/manifest.json' in Laravel, Docker & Production


You clone a fresh Laravel project, deploy to a production VPS, or boot up your Docker containers, open the application in your browser, and hit an immediate 500 exception screen:

Illuminate\Foundation\ViteManifestNotFoundException

Vite manifest not found at: /var/www/html/public/build/manifest.json

When a Blade template includes the @vite(['resources/css/app.css', 'resources/js/app.js']) directive, Laravel checks two places in strict order:

  1. First, it checks if a file named public/hot exists (which indicates the Vite development server is actively running).
  2. If public/hot does not exist, Laravel assumes the app is running in production mode and looks for public/build/manifest.json to map your compiled CSS and JavaScript bundles.

If neither file exists—or if Vite generated the manifest in a mismatched directory—Laravel throws ViteManifestNotFoundException.


Quick Diagnostic Reference

Match your environment to the exact cause below:

Symptom / Environment Underlying Cause Jump to Fix
Fresh git clone on local machine Node dependencies aren’t installed or assets haven’t been built yet Fix 1
Page loads blank with console errors pointing to http://[::1]:5173 Orphaned public/hot file left behind after killing Vite dev server Fix 2
Running inside Docker / Laravel Sail (npm run dev is running, styles broken) Vite binds to container localhost instead of 0.0.0.0 Fix 3
Works locally, throws Vite manifest not found on production VPS /public/build is gitignored and npm run build wasn’t run on deploy Fix 4
npm run build succeeds, but manifest is inside public/build/.vite/ Vite 5+ outputs to .vite/manifest.json with outdated laravel-vite-plugin Fix 5

1. Local Development: npm run dev vs. npm run build

Unlike PHP files, frontend assets in modern Laravel (9.19+, 10, 11, and 12) must be compiled by Node.js before Blade can render any view containing @vite.

Run the following commands inside your project root:

# 1. Install frontend dependencies from package.json
npm install

# 2A. If you are actively editing CSS/JS/Vue/React locally (starts HMR server):
npm run dev

# 2B. If you just want the app to load without keeping a second terminal open:
npm run build
  • npm run dev creates a temporary public/hot file and serves assets from memory on port 5173.
  • npm run build compiles and minifies your assets into static files inside public/build/assets/ and generates public/build/manifest.json.

2. The Orphaned public/hot File Trap (http://[::1]:5173)

Sometimes public/build/manifest.json does exist, yet your site loads completely unstyled and your browser console floods with ERR_CONNECTION_REFUSED or CORS errors pointing to http://[::1]:5173/@vite/client or http://localhost:5173.

Why this happens:

When you run npm run dev, Vite creates public/hot. If your terminal crashes, your Docker container stops abruptly, or you accidentally commit public/hot to Git, that file remains on disk. As long as public/hot exists, Laravel completely ignores public/build/manifest.json and forces the browser to request assets from port 5173.

How to fix it:

Delete the stale public/hot file and verify it is ignored by Git:

rm -f public/hot

Ensure your .gitignore file includes /public/hot:

/node_modules
/public/build
/public/hot
/public/storage

(Note: If your browser blocks requests between your local frontend port and backend API during development, make sure you aren’t confusing a Vite asset load failure with an API preflight block. See our guide on Fixing Laravel CORS Preflight Errors to configure cross-origin headers cleanly).


3. Fixing Vite HMR Inside Docker & Laravel Sail

When running npm run dev inside a Docker container, Vite defaults to listening on localhost (127.0.0.1) inside the isolated container network. Your host machine’s browser cannot reach it, resulting in missing styles or connection timeouts.

Step 1: Expose Port 5173 in docker-compose.yml

Ensure your application or Node service maps port 5173 to your host machine:

services:
  laravel.test:
    ports:
      - '${APP_PORT:-80}:80'
      - '${VITE_PORT:-5173}:${VITE_PORT:-5173}'

Step 2: Bind Vite to 0.0.0.0 in vite.config.js

Open vite.config.js and add a server configuration block so Vite listens on all network interfaces inside the container while telling the browser to connect via localhost:

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
    server: {
        host: '0.0.0.0',
        port: 5173,
        hmr: {
            host: 'localhost',
        },
        watch: {
            usePolling: true, // Required on Windows WSL2 / Docker volume mounts
        },
    },
});

Restart your Vite server inside the container:

docker compose exec app npm run dev
# Or with Laravel Sail:
./vendor/bin/sail npm run dev

4. Production VPS & CI/CD Deployments

By default, Laravel adds /public/build to .gitignore so compiled bundles don’t bloat your Git repository with merge conflicts.

Because /public/build is not in Git, pulling your code onto an Ubuntu production server via git pull will not include public/build/manifest.json.

The Production Deployment Fix

Include npm ci and npm run build in your production deployment script (Forge, Ploi, Envoyer, or custom bash script):

git pull origin main

# Install PHP dependencies
composer install --no-dev --optimize-autoloader

# Install exact Node dependencies from package-lock.json and compile production bundle
npm ci
npm run build

# Clear cached views so Blade reads the new manifest.json hashes
php artisan view:clear

Linux Permission Warning: Never run sudo npm run build as root on your production server. Doing so creates public/build/manifest.json owned by root:root, which can cause subsequent deployments under your standard SSH deploy user to fail with EACCES: permission denied. For proper www-data group ownership on Ubuntu and Docker, follow our guide on Fixing storage/logs/laravel.log Permission Denied.


5. Vite 5+ Upgrade Trap: .vite/manifest.json Path Mismatch

If you recently upgraded Vite to v5.0+ or v6.0+ and ran npm run build, the build finishes with zero errors—yet Laravel still throws Vite manifest not found at: .../public/build/manifest.json.

Why this happens:

Starting in Vite 5, Vite changed the default location of the generated manifest from public/build/manifest.json to a hidden subfolder: public/build/.vite/manifest.json.

If you upgraded the vite package in package.json without upgrading laravel-vite-plugin to v1.0.0+, the older plugin does not override this path, and Laravel looks in the wrong directory.

How to fix it:

Upgrade laravel-vite-plugin to its latest version and rebuild:

npm install --save-dev laravel-vite-plugin@latest
npm run build

Alternatively, if you are using a custom Vite setup without laravel-vite-plugin, explicitly pass the manifest filename in vite.config.js:

export default defineConfig({
    build: {
        manifest: 'manifest.json', // Forces output to public/build/manifest.json instead of .vite/manifest.json
        outDir: 'public/build',
    },
});

Verification

Confirm that your compiled manifest is in the exact path Laravel expects by checking the file from your terminal:

ls -la public/build/manifest.json

Once public/build/manifest.json is present and public/hot is absent (in production), clear your compiled Blade views:

php artisan view:clear

Reload your browser. Your stylesheets and scripts will load with cache-busted hashes (app-C9x2L1.css). If your forms load properly now but throw a 419 error when submitting, check our walkthrough on Fixing Laravel 419 Page Expired (CSRF Token Mismatch).