Sentry Answers>Laravel>

How do I fix the Laravel error 'Unable to locate file in Vite manifest: resources css'?

How do I fix the Laravel error 'Unable to locate file in Vite manifest: resources css'?

Richard C.

The ProblemJump To Solution

Even though you can run and browse your Laravel application, on certain pages you might encounter an error like this:

Click to Copy
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

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:

Click to Copy
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:

Click to Copy
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:

Click to Copy
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.

Further Reading

If you have difficulty getting Vite to run, read our article on the manifest.

  • SentryHow Sentry Can Improve Your Laravel Application
  • SentryLaravel Error and Performance Monitoring
  • Syntax.fm logo
    Listen to the Syntax Podcast

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Considered “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.

© 2024 • Sentry is a registered Trademark
of Functional Software, Inc.