Npm run dev stuck at APP_URL

Viewed 1584

I created a new laravel project, installed breeze auth and ran npm install and npm run dev. But it's stuck at this screen for 15 minutes now. Nothing is moving on the terminal window.

All the commands I used was

laravel new shop
composer require laravel/breeze
php artisan breeze:install
npm install
npm run dev

Everything worked fine until npm run dev, but when I enter npm run dev command, I get this output and nothing else.

PS C:\shop> npm run dev

> dev
> vite

  vite v2.9.13 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 364ms.


  Laravel v9.19.0

  > APP_URL: http://shop.test
3 Answers

I used npm run build instead npm run dev. And that solved it, I guess.

I faced the same problem. I tried for many hours to solve this problem. Laravel 9.19.0+ is using Vite to replace Laravel Mix for bundling assets. https://laravel.com/docs/9.x/vite#main-content

Starter kit components like Laravel Breeze and Jetstream have been using @vite

@vite(['resources/css/app.css', 'resources/js/app.js'])

When we run npm run dev vite will create own host below.

> dev
> vite

vite v2.9.13 dev server running at:

> Local: http://localhost:3000/
> Network: use `--host` to expose

ready in 364ms.


Laravel v9.19.0

> APP_URL: http://shop.test

And alway embed our style and script with this host http://127.0.0.1:3000/

<link rel="stylesheet" href="http://127.0.0.1:3000/resources/css/app.css">
<script type="module" src="http://127.0.0.1:3000/resources/js/app.js"></script>

I found a file name hot in the folder public was been created during we run command npm run dev and it is never delete.

To work around I just delete hot file by add few code into package.json

From

"scripts": {
    "dev": "vite",
    "build": "vite build"
},

To

"scripts": {
    "delhot": "npx rimraf public/hot",
    "dev": "vite",
    "build": "npm run delhot vite build"
},

I hope that next release version of Laravel Vite will fix this issue.

Laravel version 9.19.0 replaced Mixer with Vite for more information check Bundling Assets (Vite)

if you want to work mixer install Laravel version /= 9.1.0

composer create-project Laravel/Laravel app_name 9.1.0

Related