Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Marin1's avatar

Laravel app.js not found

When I run php artisan serve in my new Laravel project, I get a blank page at localhost. The console says Failed to load resource: the server responded with a status of 404 (Not Found) for my app.js. This is my app.js:

import './bootstrap';

require('./bootstrap');

require('./components/HelloReact')

I saw a post that said to run npm run dev. When I run it, I get the following error:

failed to load config from /Users/marinjohnson/guide-to-laravel-and-react/vite.config.js
error when starting dev server:
Error: Dynamic require of "file:///Users/marinjohnson/guide-to-laravel-and-react/node_modules/laravel-mix/src/index.js" is not supported
    at file:///Users/marinjohnson/guide-to-laravel-and-react/vite.config.js.timestamp-1702918474608-46af1098049d9.mjs:6:9
    at file:///Users/marinjohnson/guide-to-laravel-and-react/vite.config.js.timestamp-1702918474608-46af1098049d9.mjs:20:11
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
    at async loadConfigFromBundledFile (file:///Users/marinjohnson/guide-to-laravel-and-react/node_modules/vite/dist/node/chunks/dep-68d1a114.js:66329:21)
    at async loadConfigFromFile (file:///Users/marinjohnson/guide-to-laravel-and-react/node_modules/vite/dist/node/chunks/dep-68d1a114.js:66178:28)
    at async resolveConfig (file:///Users/marinjohnson/guide-to-laravel-and-react/node_modules/vite/dist/node/chunks/dep-68d1a114.js:65774:28)
    at async _createServer (file:///Users/marinjohnson/guide-to-laravel-and-react/node_modules/vite/dist/node/chunks/dep-68d1a114.js:65051:20)
    at async CAC.<anonymous> (file:///Users/marinjohnson/guide-to-laravel-and-react/node_modules/vite/dist/node/cli.js:763:24)

I then saw another post that recommended upgrading node to 16.16 or 16.11.1. I tried both these versions, as well as the latest version, but I got the same error when running npm run dev. I also tried npm run build instead, but that also didn't work.

Any help would be appreciated.

0 likes
2 replies

Please or to participate in this conversation.