How do I fix the Laravel error 'Unable to locate file in Vite manifest: resources css'?
Richard C.
—Even though you can run and browse your Laravel application, on certain pages you might encounter an error like this:
Unable to locate file in Vite manifest: resources something.css
The error occurs because you have not built and run the frontend code correctly. While you will not get this error running a default Laravel installation, if you add an extra package like Livewire or Jetstream your JavaScript and CSS dependencies will change.
Your vite.config.js
file will probably have a line for the file that matches the error you get, such as input: ['resources/css/app.css', 'resources/js/app.js']
.
The solution to this problem is to download and build the JavaScript code. Ensure that npm is installed on your computer and in a terminal in your project folder, run:
npm install npm run dev
The commands above will install JavaScript modules and make them available to the browser. You still need to run the PHP server to browse your project:
php artisan serve
These commands are useful when running in development so code changes are available to the browser by the hot-reload servers. However, when running in production, rather run the command below to bundle all your frontend code:
npm build
This command runs vite build
that bundles your assets into the public/build
folder. There is no need for the Vite or Artisan dev server because your production machine will make everything available to the browser through the Apache web server.
If you have difficulty getting Vite to run, read our article on the manifest.
Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.
SEE EPISODESConsidered “not bad” by 4 million developers and more than 100,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.
Here’s a quick look at how Sentry handles your personal information (PII).
×We collect PII about people browsing our website, users of the Sentry service, prospective customers, and people who otherwise interact with us.
What if my PII is included in data sent to Sentry by a Sentry customer (e.g., someone using Sentry to monitor their app)? In this case you have to contact the Sentry customer (e.g., the maker of the app). We do not control the data that is sent to us through the Sentry service for the purposes of application monitoring.
Am I included?We may disclose your PII to the following type of recipients:
You may have the following rights related to your PII:
If you have any questions or concerns about your privacy at Sentry, please email us at [email protected].
If you are a California resident, see our Supplemental notice.