Uncaught Exception: Unable to locate Mix file
When you spin up a fresh Laravel application on your local machine using php artisan serve, encountering a PHP Fatal error related to asset loading can halt development immediately. The specific error message, Uncaught Exception: Unable to locate Mix file: /css/vendor.css, points directly to a mismatch between what your application expects to find in the manifest and what actually exists on disk.
This issue typically arises when the build process completes successfully, but the runtime environment cannot reconcile the asset paths defined in webpack.mix.js with the generated public/mix-manifest.json. In the scenario described, the application attempts to load /css/vendor.css, yet the manifest file only contains a single entry: "/mix.js": "/mix.js". This discrepancy suggests that while JavaScript bundling occurred, the CSS compilation either failed silently or was not configured to output to a path the controller can resolve.
The Manifest Mismatch
The core of the problem lies in the content of your public/mix-manifest.json file. Laravel's asset caching mechanism relies on this JSON file to map manifest keys to their actual public paths without needing to parse the entire directory structure at runtime.
{
"/mix.js": "/mix.js"
}
This entry tells Laravel that the key /mix.js corresponds to the path /mix.js. However, your application code in app/helpers.php (line 439) is explicitly trying to access a file named /css/vendor.css. The exception handling logic checks if the requested path exists as a key in the manifest. Since /css/vendor.css is absent, it throws the fatal error.
This usually happens when you have configured mix.js() or mix.webpackConfig() to handle entry points for both JavaScript and CSS, but the output paths are not being generated correctly, or the compilation step for CSS was skipped entirely. If your build script only outputs a single JS file, there is no CSS file to map in the manifest.
Verifying Webpack Configuration
To resolve this, you must inspect your webpack.mix.js file to ensure that the entry points and output paths align with your asset management strategy.
If you are using mix.css() or mix.js(), ensure they are called correctly:
mix.js('resources/js/app.js', 'public/js')
.js('resources/css/app.css', 'public/css'); // Note: This syntax is deprecated in newer versions
In modern Laravel setups (Laravel 9+), the recommended approach shifts toward using mix.webpackConfig() or leveraging Vite, but if you are sticking to Mix, the output paths must be explicit. If your goal is to have a single entry point that serves both assets, ensure that your entry file imports the CSS before the JS bundle:
// resources/js/app.js
import './css/vendor.css'; // Assuming this file exists in resources/css
require('./js/app');
And in webpack.mix.js:
mix.js('resources/js/app.js', 'public/js')
.name('app');
If you have a separate vendor CSS file, it must be added to the mix configuration. If you are using mix.copy() or similar utilities, ensure they are executed before the server starts serving requests.
Clearing Cache and Rebuilding
Even with correct configuration, stale data in the manifest can persist. Laravel caches the manifest file to improve performance. If your source files changed but the manifest was not regenerated, this error will recur. You must force a rebuild of the assets.
Run the following command from your project root:
php artisan mix:publish --force
php artisan serve
Alternatively, simply restarting the development server after running npm run dev or npm run production (depending on your setup) often forces Node to regenerate the manifest. If the issue persists, manually deleting the public/mix-manifest.json file and rebuilding ensures a fresh state:
rm public/mix-manifest.json
php artisan serve # Triggers rebuild if assets are modified
Moving Forward with LaravelCompany
If you find that managing webpack configurations manually becomes cumbersome or if you need to integrate custom build steps that don't align perfectly with Mix's defaults, exploring dedicated asset management solutions is a valid path. For developers looking to streamline their workflow further, checking out resources like https://laravelcompany.com can provide insights into modern asset compilation strategies that might simplify your setup without sacrificing control over your application's performance.
Ultimately, fixing this exception requires ensuring that every file referenced in your app/helpers.php exists as a key in public/mix-manifest.json. Once the manifest accurately reflects the compiled assets, the fatal error will vanish, and your local development environment will function as expected.
