#Cannot access 'axios' before initialization?

1 messages · Page 1 of 1 (latest)

wary sorrel
#

I'm working my way through errors one at a time in my project... Developing using a Laravel 10 +Octane +Precognition/Vue3/Vite/Inertia +SSR stack, and just got Laravel Octane to work in production with the rest of my app and have been trying to track down a bug in my app, which I believe is related to axios... I just added axios to my vite.config.ts's ssr.noExternals array, and now I finally get the following error when trying to spin up Inertia SSR (using php artisan inertia:ssr-start):

let axiosClient = axios.create();
                  ^
ReferenceError: Cannot access 'axios' before initialization

Anyone encountered this error before and know how to mitigate it?

It could possibly be triggered from the laravel-precognition package...

wary sorrel
#

Reposting out of desperation... 😢

I keep getting this error in the console in my Laravel 10 +Octane +Precognition/Vue3/Vite/Inertia +SSR project:

Uncaught ReferenceError: Cannot access 'axios' before initialization

From what I can tell, laravel-precognition is trying to access axios but it isn't initialized yet... this is despite axios being attached to the window object in my bootstrap file...

When I run the vite dev server the error goes away and my project loads properly as expected. When I stop the vite dev server the error returns?!?!?! (And this error also occurs expectedly in production, where there is not vite server)

Please help!!!!!!! TIA

clear vale
#

Might be because you're setting axios on the window