Skip to content

Vite Manifest Not Found: Solutions for Laravel Applications

Problem Statement

When deploying Laravel applications with Vite to production environments (particularly cPanel shared hosting), developers frequently encounter the "Vite manifest not found" error. This error occurs when Laravel cannot locate the manifest.json file that Vite generates during the build process, typically showing this message:

Vite manifest not found at: /path/to/public/build/manifest.json

Missing Vite Manifest File
Did you forget to run `npm install && npm run dev`?

The issue often arises due to:

  • Incorrect file structure in cPanel environments
  • Missing build files in production
  • Node.js version incompatibility
  • Incorrect configuration for non-standard directory layouts

Primary Solutions

1. Build Assets for Production

The most common solution is to ensure you've built your assets for production:

bash
npm install
npm run build

WARNING

The public/build directory is typically in .gitignore. You must run npm run build on your production server or include the built files in your deployment process.

2. Verify Node.js Version Compatibility

Vite requires a modern Node.js version (16+). Check your Node.js version:

bash
node --version

If outdated, upgrade using nvm (Node Version Manager):

bash
nvm install 20
nvm use 20

Or on Ubuntu systems:

bash
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

3. Adjust Configuration for cPanel Directory Structure

cPanel often requires moving public files to public_html. Update your vite.config.js:

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

export default defineConfig({
    plugins: [
        laravel({
            input: 'resources/js/app.js',
            // Add public directory configuration for cPanel
            buildDirectory: 'build',
            publicDirectory: '../public_html' // Adjust based on your structure
        }),
    ],
});

4. Update Laravel's Public Path (Advanced)

For complex directory structures, modify public/index.php:

php
<?php

use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

// ... existing code ...

$app = require_once __DIR__.'/../bootstrap/app.php';

// Set custom public path
app()->usePublicPath(__DIR__);

$app->handleRequest(Request::capture());

Alternative Approaches

Use Build Directory Customization

In AppServiceProvider.php, you can customize the build directory:

php
<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Vite;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Vite::useBuildDirectory('.');
    }
}

Manual Build Folder Management

For cPanel deployments with separated directories:

  1. Run npm run build locally
  2. Upload the generated build folder to both locations:
    • Your application's public directory
    • The public_html directory (if using cPanel's standard structure)

TIP

This ensures Laravel finds the manifest regardless of which path it's checking.

File Permission Issues

If the manifest file exists but isn't accessible, check permissions:

bash
sudo chown www-data:www-data -R public/build/
sudo chmod g+w -R public/build/

Complete cPanel Deployment Checklist

  1. Verify Node.js version (16.0+ recommended)
  2. Install dependencies: npm install
  3. Build assets: npm run build
  4. Check directory structure matches your deployment
  5. Verify file permissions for the build directory
  6. Update configuration if using non-standard public directory

DANGER

Never run npm run dev in production. This command starts a development server and is not suitable for production environments. Use npm run build instead.

Troubleshooting Common Issues

  • Build failures: Check console output for specific errors during npm run build
  • Missing dependencies: Ensure all required packages are in your package.json
  • Caching issues: Delete node_modules and reinstall if encountering strange behaviors
  • Path conflicts: Double-check all path configurations in both Laravel and Vite

By following these solutions, you should resolve the "Vite manifest not found" error and successfully deploy your Laravel application with Vite bundling.