Skip to content

Livewire is not defined after fresh install new laravel project with jetstream #1106

@limkuncui

Description

@limkuncui

I just do a fresh install latest laravel version 9.22.1 with jetstream.
I'm running on Windows with latest apache server, php 8 and mysql env.

I run

laravel new project_name --jet

after fresh installation
I got Livewire is not defined. I notice every page console log have Livewire is not defined error.

console error log:
GET http://localhost/vendor/livewire/livewire.js?id=c69d0f2801c01fcf8166 net::ERR_ABORTED 404 (Not Found)
dashboard:337 Uncaught ReferenceError: Livewire is not defined
at dashboard:337:27

The profile page doesn't have name and email pre filled due to this error as well.

console error log:
Failed to load resource: the server responded with a status of 404 (Not Found)
profile:770 Uncaught ReferenceError: Livewire is not defined
at profile:770:27

the console error: Ilivewire is not defined because it can't locate livewire.js file. It doesn't exists right after installation with jetstream.

After reading livewire installation/configuration at: https://laravel-livewire.com/docs/2.x/installation
I run the following at console:

php artisan livewire:publish --assets

Copying directory [laravel_project\vendor\livewire\livewire\dist] to [laravel_project\public\vendor\livewire]
including livewire,js

php artisan livewire:publish --config

Copying file [laravel_project\vendor\livewire\livewire\config\livewire.php] to [laravel_project\config\livewire.php]

edit laravel_project\config\livewire.php
'asset_url' => env('ASSET_URL'),

edit laravel_project.env file and add
ASSET_URL=http://localhost/laravel_project
or
ASSET_URL=http://laravel_project/

php artisan config:cache

after the fresh installation the livewire.js script is linked starting with /livewire/livewire.js .
I think the livewire.js script is better linked directly starting with http://localhost/your_website_public_url
After I do the above steps the profile page have name & email pre-field correctly and no console log error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions