I installed laravel and I'm trying to use inertia with it, but when after installing it and almost getting it to work, I'm now getting this error in my console
[Vue warn]: Error in render: "SyntaxError: Unexpected token u in JSON at position 0"
For anyone else looking for the solution. This happens because you haven't run the @inertia directive within your template file. Note: you cannot run this directive within a layout file, it has to be within the main template that Inertia is using.
This template file is defined within the App\Http\Middleware\HandleInertiaRequests middleware as a protected variable called $rootView.
The app.js file posted here does not compile here with npm run watch following only the official guide. And i do have @inertia placed in my app.blade.php but still the same error.
For anyone who still might Google this: I had a slightly different issue that was causing the error. My main template file app.blade.php had a <body id="app">.
The @inertia tag also renders a <div id="app>", with a whole bunch of data in the data-page attribute. This resulted in a page with a double #app element which obviously broke everything, so removing the id from the body tag fixed the issue.