How to Install Vue.js in Laravel 8 - vue.js

I am using laravel 8 and now I want install Vue.js. I am trying like this
composer require laravel/ui
php artisan ui vue
php artisan ui vue --auth

UPDATE: If you want to completely avoid Inertia / Livewire (Alpine.js) scaffolding in your Laravel ^8.0 applications and use Vue instead - install Laravel UI, which will most likely be maintained indefinitely (scaled to practical software lifetime).
Instructions for installing Vue (and old auth scaffolding) in your Laravel app:
run composer require laravel/ui
run php artisan ui vue for just installing Vue.
run php artisan ui vue --auth for scaffolding out the auth views.
run npm install && npm run dev
How ever, if you still want to use Vue.js with Livewire scaffolding, use the following instructions.
IMPORTANT: Please note that Vue.js takes control of the DOM once installed, detaching nodes and replacing it, removing other JS listeners. So, if you are using Livewire on the same page with Vue, the Alpine.js that comes with Livewire scaffolding wont work. As a workaround you can use Livewire VueJS support plugin.
run npm install --save vue
Add the following to your resources/js/app.js:
window.Vue = require('vue');
Vue.component('example-component', require('./components/ExampleComponent.vue').default);
const app = new Vue({
el: '#app',
});
Create an ExampleComponent.vue in the resources/js/components directory
<template>
<div>Hello World.</div>
</template>
<script>
export default {
mounted() {
console.log("Example component mounted");
}
};
</script>
Add <script src="{{ asset('js/app.js') }}" defer></script> in the <head> section of your layout file (resources/views/layouts/app.blade.php)
Add id="app" to <body> or main <div> in your layout file (resources/views/layouts/app.blade.php)
Add <example-component /> to your view
Run npm run dev or npm run watch
Finally, open up the devtools, and in the console log you should see Example component mounted

In laravel 8 project run following commands to install vue.js
run composer require laravel/ui
Install Vue php artisan ui vue
Install Vue with auth php artisan ui vue --auth
run npm install && npm run dev

I wasted so much time with this and don't want people to go through the same, so I will teach you how to install Vue.js and make it work fast.
If you want to start from scratch
replace the LaravelProject with your project name
laravel new LaravelProject
Install Vue.js on your Laravel 8 application
run the following commands
composer require laravel/ui
php artisan ui vue
php artisan ui vue --auth
npm install
npm run dev
npm run watch
Now that you have installed everything you need, go to a blade view and add the following code inside <body></body>
<div id="app">
<example-component />
</div>
<script src="{{ mix('/js/app.js') }}"></script>
If you did everything right you will see the following text on the rendering of your view
Example Component
Im an example component.
And in your console:
Component mounted.

You can install Vue 3 on your laravel project via three different ways:
Import it as a CDN package on the page
Download the JavaScript files and host them yourself
Install it using npm
1. Via CDN
include following code in your HTML file:
<script src="https://unpkg.com/vue#next"></script>
or use the following link for production:
https://cdnjs.com/libraries/vue
2. Download and Host yourself:
Download it from GitHub here:
https://github.com/vuejs/vue-next
3. Via npm
npm is the recommended installation method when building large scale applications with Vue. It pairs nicely with module bundlers such as Webpack (opens new window)or Rollup (opens new window). Vue also provides accompanying tools for authoring Single File Components.
Run this command in your terminal to get the latest stable version
$ npm install vue#next
Followed by:
npm install

Run a Command
npm install vue
In resources/js/bootstrap.js
window.Vue = require("vue/dist/vue.min");
And then run command
npm run dev

You can try npm install --save vue

You can install vue on laravel 8 by simply running below commands to install laravel ui:
composer require laravel/ui
And if you want authorizations such as login page, registartion page scaffolding then run below command from the folder where laravel project is installed:
php artisan ui vue
After running above commands run to install all dependencies and compile all style resources:
npm install
npm run dev
npm run watch

Setting up Vue in Laravel
run composer require laravel/ui
Install Vue php artisan ui vue
if you Install Vue with auth use php artisan ui vue --auth
add after in page master
run npm install
run npm run dev
run PHP artisan serve

In existing project of Laravel 8 it's better to do this installation which gets in one line:
npm i -D vue#next #vue/compiler-sfc vue-loader#next
For your project to work correctly it's also important to check webpack.mix.js, it should look this way:
mix.js('resources/js/app.js', 'public/js').vue()
.postCss('resources/css/app.css', 'public/css', [
//
]);
As well while working with project don't forget:
npm run watch
Hope it was helpful!

A pretty simple and straightforward set of instructions
https://laravel2020.com/2022/01/25/how-to-install-vue-3-on-an-existing-laravel-8-project/

**Install Vue + Laravel 8
composer create-project laravel/laravel projectName --prefer-dist
composer require laravel/ui
php artisan ui vue
npm install
npm run dev
npm i vue-loader
npm install vue-router vue-axios
npm run dev
Success.

Related

jetstream css and js not working on my laravel 8, all the page broken

in my laravel 8 project i install jetstream by the following command.
composer require laravel/jetstream
then i put the following command
php artisan jetstream:install livewire
then i give the command npm install and npm run dev and run migration.
but when i run my laravel project my login, registration and all other jetstream page broken. it seems css and js are not working. i have followed all the existing stackoverflow process but no improvemnet.
this is registration page image

Issues with Vue installation

I'm new to Vue, this may seem a basic question but I'm stuck with this problem:
I have installed Vue 3 using npm, according to the documentation:
https://v3.vuejs.org/guide/installation.html#npm
I have included Vue to my html file, like so:
<script src="../node_modules/vue/dist/vue.csj.js"></script>
But I get this error in the console:
vue.cjs.js:3 Uncaught ReferenceError: exports is not defined
at vue.cjs.js:3 (anonymous) # vue.cjs.js:3
I have seen some similar issues and I know it has something to do with browser compatibility and webpack; like the browser does not natively recognise import/export commands but it seems like everything is installed correctly and I don't know how to solve this issue. I couldn't find anything helpful in the documentation.
So my question is
How do I successfully install Vue and include it in my working files?
I don't think you followed that guide correctly. I would recommend you install the Vue CLI, then create your app using the cli:
$ npm install -g #vue/cli - install cli
$ vue create my-app
https://cli.vuejs.org/
However, if you don't want the CLI, I'd recommend a CDN:
<script src="https://unpkg.com/vue#next"></script>
Or you can just copy the contents of the file to your app, maybe vue.js
(https://unpkg.com/vue#next).
And you then on your html <script src="vue.js"></script>
Firstly ,
npm install -g #vue/cli After ,
on commandline run vue ui
and create a project

How to install vue.js version 2

I want to install version 2 of vue.js to use vuetify. However, I don't know the command for that. Could someone pass the command to me please
If you are looking for a specific version of Vue2 you can run the following command with npm: npm install vue#2.x.x or if you want the latest, simply npm install vue.
For vue3 it is: npm install vue#next
Сreated a new Vue.js project using Vue CLI. Select during installation Vue2
vue create my-app
# navigate to new project directory
cd my-app
Add vuetify
vue add vuetify
npm install vue#2.x.x --save
It will update package.json as well.
so later on, if you need to install the project from git, by running
npm install
easily package can be installed

Vue: not responding to commands

I installed vue using
npm install vue
But the terminal wasn't recognizing "vue" command (like vue --version), so I hitted:
npm install -g vue-cli#2.7.0
And now it says I have version 2.7.0 when I check the version, but it doens't respond neither shows any error when I try:
vue ui
It just doesn't run. Can anyone help?
That is no longer the name of the Vue CLI package. You will need to install from #vue/cli as detailed here: https://cli.vuejs.org/guide/installation.html

Issues installing angular2-meteor with npm

Trying to start a new angular2-meteor project using
npm install angular2-meteor --save
Get a whole bunch of red errors (below) and I am not sure what they mean. I have already done
npm install npm -g
and
npm update -g
Here's the error:
I think you followed the Quick Start here.
angular2-meteor package has not been exposed to NPM yet.
Check this issue
UPDATE:
Refer here and here for latest tutorial.
Now you can install, follow these steps:
Update your meteor globally (If you already updated, then no need to do it again. And go here to check if there is a new version).
meteor update --release 1.3-rc.4
Run these in your terminal to create an angular2-meteor1.3 project:
meteor create --release 1.3-rc.4 hello
cd hello
npm install https://github.com/Urigo/angular2-meteor --save
npm install https://github.com/Urigo/angular2-meteor-auto-bootstrap --save
meteor remove blaze-html-templates
meteor add angular2-compilers
Remove main.js, main.html, main.css files in the client folder.
Then create these two files in your client folder:
// app.ts
import 'reflect-metadata';
import { bootstrap } from 'angular2-meteor-auto-bootstrap'
import { Component } from 'angular2/core';
#Component({
selector: 'app',
template: `<p>Hello World!</p>`
})
class App {}
bootstrap(App);
(Make sure you put import 'reflect-metadata'; first line before other import, otherwise it won't work.)
// index.html
<head>
<title>Hello</title>
</head>
<body>
<app></app>
</body>
At last, run meteor in the terminal and go to http://localhost:3000 to check your app.