laravellaravel-livewirealpine.jslaravel-filamentfilamentphp

Alpine Expression Error: error is not defined


Project with TALL (Tailwind, Alpine, Laravel, Livewire) Stack and Filament

I got in local/dev mode the follwing warning (in prod it does not happens, so it maybe has todo with some dev-packages?):

Alpine Expression Error: error is not defined

Expression: "error"

 <div x-show=​"error" x-text=​"error" class=​"text-sm text-danger-600 dark:​text-danger-400" style=​"display:​ none;​">​</div>​ 

And the associated error in my console:

Uncaught ReferenceError: error is not defined
    at [Alpine] error (eval at safeAsyncFunction (livewire.js?id=cc800bf4:1176:21), <anonymous>:3:32)
    at livewire.js?id=cc800bf4:1198:23
    at tryCatch (livewire.js?id=cc800bf4:1118:14)
    at livewire.js?id=cc800bf4:3609:19
    at reactiveEffect (livewire.js?id=cc800bf4:2417:18)
    at Object.effect2 [as effect] (livewire.js?id=cc800bf4:2392:7)
    at effect (livewire.js?id=cc800bf4:763:35)
    at wrappedEffect (livewire.js?id=cc800bf4:779:29)
    at Function.<anonymous> (livewire.js?id=cc800bf4:3609:5)
    at flushHandlers (livewire.js?id=cc800bf4:1283:48)

I search google, the filament discord channel etc. but havent found anything similar. I dont know where this error exactly come from and how to fix it. Anyone some tipps?


Solution

  • The link in @TUPKAP 's comment (https://github.com/filamentphp/filament/discussions/12845) lead me to the answer, but posting an answer here for others who land on this question.

    You likely have old JavaScript code from a previous version of filament. The fix for this and other similar errors (mine was Alpine Expression Error: table is not defined) is to update the filament scripts by running the following command:

    php artisan filament:upgrade
    

    That command should clear the cache and views, but some people reported that they also needed to run the following commands after:

    php artisan view:clear
    php artisan optimize:clear