Unable to locate file in Vite manifest: resources/js/app.jsx. (npm run build)

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company

Solving the Vite Build Mystery: Why Unable to locate file in Vite manifest Happens

As developers diving into the world of full-stack frameworks like Laravel combined with modern frontend tooling like Vite, you often encounter frustrating build errors. One specific error that plagues many users is: Unable to locate file in Vite manifest: resources/js/app.jsx. This message signals a breakdown in how Vite—the build tool—is mapping your source files to the final output structure.

This post will diagnose why this happens, especially when npm run dev works perfectly but npm run build fails, and provide concrete steps to resolve this issue.

The Dev vs. Build Discrepancy Explained

The core of the problem lies in the difference between the development server (npm run dev) and the production build process (npm run build). While both commands rely on the same Vite configuration, they execute different phases with different expectations regarding file resolution and asset bundling.

When you run npm run dev, Vite is typically running in a watch mode, which is highly forgiving. It might resolve paths dynamically or handle temporary file states more leniently. However, when executing npm run build, Vite performs a strict static analysis of your project structure against the configuration defined in vite.config.js. If there is a slight mismatch in how entry points are defined, or if the asset location is relative to an unexpected root directory, the build process immediately throws this manifest error.

This often happens in Laravel/Vite setups where the public directory handling or the base path for assets isn't perfectly synchronized between the development server and the production bundler.

Step-by-Step Troubleshooting Guide

Here are the most common causes and solutions for resolving the Unable to locate file in Vite manifest error:

1. Verify the Entry Point Configuration

The first place to look is your vite.config.js file. Ensure that the entry points you define exactly match the physical location of your source files.

If your React application code resides in a directory like resources/js/app.jsx, make sure Vite is correctly pointing to it.

Example vite.config.js Check:

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

export default defineConfig({
    plugins: [
        laravel({
            input: [
                'resources/js/app.jsx', // Ensure this path is correct relative to the project root
                'resources/css/app.css',
            ],
            refresh: true,
        }),
        // ... other plugins
    ],
});

If you are using a custom setup or if your file structure has changed, double-check that the path listed under input is accurate. A common mistake is forgetting the ./ prefix or including incorrect casing.

2. Check File Location and Casing

File system issues are often overlooked. Even if the path looks correct in your code, check the actual file structure on your disk. Ensure that resources/js/app.jsx exists exactly as named. Pay close attention to case sensitivity, especially when developing on Linux-based environments (which is common for deployment).

3. Review Asset Handling and Public Directory

In Laravel applications, assets are often served via the public folder. While Vite manages the compilation process, ensure that any base paths or asset references used within your JavaScript code correctly account for where the compiled files will end up during the build phase. When building production assets, errors often surface here if the path resolution fails.

Best Practices for Robust Vite Builds

To prevent these kinds of headaches in larger projects, adopt these best practices:

  1. Use Absolute Paths (When Possible): While relative paths are fine within a module, defining entry points using absolute references or clear configuration ensures consistency across different build environments.
  2. Isolate Build Steps: Keep your vite.config.js focused purely on bundling logic. Keep environment setup (like Laravel routing or dependency management) separate from the asset compilation itself. This aligns with robust architectural principles, similar to how modern frameworks advocate for clear separation of concerns when building complex systems, much like the principles discussed at https://laravelcompany.com.
  3. Test Locally First: Always run npm run build immediately after making changes to your configuration files. If you encounter an error, step back and check the file system structure before diving deep into the Vite configuration.

Conclusion

The error Unable to locate file in Vite manifest: resources/js/app.jsx is almost always a symptom of a configuration mismatch between the development environment and the production build environment, rather than a fundamental bug in the code itself. By meticulously reviewing your vite.config.js, verifying absolute file paths, and understanding the difference between dev and build modes, you can efficiently resolve this issue and ensure smooth deployment of your Laravel/Vite applications. Happy coding!