Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'default')

I have just setup Intertia with Vue and laravel and I can't seem to get the pages to load I am having this error enter image description here

Here is the setup

app.js

import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'

createInertiaApp({
  resolve: async (name) => {
    const pages = import.meta.glob('./Pages/**/*.vue')

    return (await pages[`./Pages/${name}.vue`]())
  },
  setup({ el, App, props, plugin }) {
    createApp({ render: () => h(App, props) })
      .use(plugin)
      .mount(el)
  },
})

IndexController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class IndexController extends Controller
{
    public function index()
    {
        return inertia('Index/Index');
    }
    public function show(){
        return inertia('Index/Show');
    }
}

web.php

Route::get('/', [IndexController::class, 'index']);
Route::get('/show', [IndexController::class, 'show']);

here is just some basic vue template Index.vue

<template>
    <div>index</div>
</template>

I expect for the index.vue to be displayed just showing the simple text index

like image 582
wale Avatar asked Oct 15 '25 08:10

wale


2 Answers

Solved the issue was having the Pages folder in the wrong folder The pages folder should be in resources/js/Pages. My mistake was having the pages folder in resources/js

like image 156
wale Avatar answered Oct 17 '25 10:10

wale


For me, it was writing .vue in my path:

return Inertia::render('Dashboard/Admin/Home.vue'); // wrong

I removed .vue and problem solved

return Inertia::render('Dashboard/Admin/Home'); // correct
like image 22
eylay Avatar answered Oct 17 '25 08:10

eylay



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!