In a new Laravel project created by the installer with the Jetstream option resources/js/app.js
has a line that reads:
Vue.mixin({ methods: { route } });
PHPStorm reports that route
is an unresolved variable or type. This happens, PHPStorm can be wrong. In a newly created application this does not cause an error.
However, when I upgraded an existing project to Laravel 8.10.0 and installed Jetstream via composer this does cause and issue. When running this npm run dev
does not error, but the browser will report app.js:44258 Uncaught ReferenceError: route is not defined
.
I can find no difference in app.js
or bootstrap.js
that would cause this. Where does this get imported or included so that I can check if it was done correctly in my upgrade?
The newly created app and the update both create a Blade template that includes the
@routes
directive. As I was comparing existing files I did not notice this difference.This can be corrected by including the
@routes
directive in your blade template prior to the main scripts being loaded, as documented in the installation guide for ziggy.