Vue setup: Can't resolve 'ziggy' in '[project path]\resources\js\pages'
See original GitHub issueDescription
I’ve tried to set up ziggy in my Laravel/Vue MPA project, following the instructions for javascript frameworks and vue. I ran php artisan ziggy:generate
and set it up in my javascript file like show in the instructions, with a Vue mixin. The issue is the following line:
import route from 'ziggy';
When I build with yarn watch, I get this error:
ERROR in ./resources/js/pages/welcome.js Module not found: Error: Can't resolve 'ziggy' in '[my project path]\resources\js\pages' @ ./resources/js/pages/welcome.js 6:0-27 12:13-19 @ multi ./resources/js/pages/welcome.js ./resources/css/app.css
I’m probably missing something, do I have to install a seperate npm package, or where do I get this module from? I found nothing in the documentation.
Expected behavior
Not getting an error, probably.
Environment
- Laravel version: 8.16.1
- Ziggy version: 1.0.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Ohhh, I see. I learned about ziggy in a thread on Laracasts, and I thought that it does exactly that. Thank you for clarifying.
Take a look at the section of the Readme on setting up Ziggy with Javascript frameworks. With Mix 5 it would look like this:
Like Laravel’s helper, Ziggy’s
route()
function returns a string, it doesn’t perform any navigation for you. YourgoToLogin()
method will return something likehttp://my-app.test/login
, whether/how you navigate to that page is up to you.