I know some Vue and I'm attempting to learn about Laravel how do I add Vue to a Laravel app? I've tried a couple of things on Stack Overflow and here yet regardless of what I try I can't get it to work.
I've tried this:
npm install vue
which install vue and I try create a component but I can't seem to get it to render I've tried adding <script src="{{ mix('js/app.js) }}"></script>
to my blade file
and this:
php artisan ui vue
which creates the scaffold correctly it says to run npm install && npm run dev
yet every time I do this it fails. I've added .vue
to mix file so this is currently:
mix.js('resources/js/app.js', 'public/js')
.vue()
.sass('resources/sass/app.scss', 'public/css');
It says additional dependencies are needed:
Running: npm install vue-loader@^15.9.7 --save-dev --legacy-peer-deps.
Finished. Please run Mix again.
Then it just fails:
npm ERR! code ELIFECYCLE
npm run development
npm ERR! errno 1
npm ERR! @ dev:
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
How do I run Mix again? npm run dev
, npm run hot
both fail what am I doing wrong?
Top comments (3)
I thing you should uninstall everything about Vue you have installed manually.
All you need to do to get vue running is to make sure this is present. Mix will automatically install the required node modules.
And also make sure this is referenced in your app
welcome to the laravel community. I find using inertiajs inertiajs.com/ makes it easier to add vue for me.
And also welcome to the laravel community.
Check out Laracasts.
Ideally that should be where this kind of question should be.
Goodluck on your journey