I am learing Laravel, and following a fullstack tutorial. The application is Laravel+Vue.
When I started Laravel on port 8000 with php artisan serve
it opened as it should. Then I created Vue app inside src folder. It should be started with command npm run dev
on port 5173. When I open it, I don’t see default Vue starting page:
I only see this:
How can I start the right server on right port to make frontend of my app?
This is my App.vue:
import HelloWorld from "./components/HelloWorld.vue";
import { mapState } from "vuex";
export default {
components: { HelloWorld },
computed: { ...mapState(["user"]) },
};
</script>
<template>
<div>
<h2>Bok</h2>
<pre>{{ user }}</pre>
</div>
<HelloWorld msg="Vite + Vue" />
</template>
<style scoped>
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
And this is my index.js:
const { createStore } = require("vuex");
const store = createStore({
state: { user: { data: { name: "Zura" }, token: null } },
getters: {},
actions: {},
mutations: {},
modules: {},
});
export default store;
2
Answers
The first and main problem was that the app was started from the wrong folder. It needs to be started from vue subfolder:
laravel: myapp>
php artisan serve
vue: myappvue>
npm run dev
The second problem was that after opening localhost:5173 nothing was shown: I needed to change
const { createStore } = require("vuex");
toimport { createStore } from "vuex";
I think you see what you should, im currently working on laravel-vue-vite project and when i installed it i also had Laravel dashboard
To run laravel localy
And for vite you run
For localy
For production
Note that they both should be run at same time in Visual studio code to do that you need open second terminal so press "+" icon in right top corner of terminal
If you installed laravel with vue your views are stored in resources/js
And routes in routes/web.php