#ERROR: Accessing import.meta directly is unsupported

1 messages · Page 1 of 1 (latest)

acoustic star
#

I am installing Inertia + Vue 3 into a well established Laravel 10 application. I have followed the Inertia tutorial for installing Inertia + Vue3 meticulously. I have simultaneously been watching Laracasts Jeffrey Way in his tutorial. I have tried 3 times now to make this work without luck. I keep getting this error above. Note: I use MIX, not Vite. The error comes off of this code, which you are supposed to enter into app.js, or bootstrap.js. I am not getting any output from my Vue.component. Furthermore, my IDE ( PHPStorm) tells me that the createInertiaApp function, the Promise returned is ignored. My page view is just plain white clean. Any ideas?? Many thanks

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

createInertiaApp({
  resolve: name => {
    const pages = import.meta.glob('./Pages/**/*.vue', { eager: true })
    return pages[`./Pages/${name}.vue`]
  },
  setup({ el, App, props, plugin }) {
    createApp({ render: () => h(App, props) })
      .use(plugin)
      .mount(el)
  },
})

neon harness
#

You're using Vite syntax there, that won't work. Think the Inertia legacy docs have the info for Mix

resolve: name => require(`./Pages/${name}`),
acoustic star
#

Thanks for your help. I tried replacing the one suggested line and that did not work. So I replaced the whole block of code and YUP, that worked! The docs should say that the code is optimised for Vite. I tried ripping Mix out and replaicing with Vite, but there were so many conflicts with the Bootstrap framework I gave up. Many Thanks!!

neon harness
acoustic star
#

Yes, I saw that, and tried swapping out the single line. I did not realise I had to swap out the two lines. The obvious escaped me. Thanks again.

#

How do I set this as "solved".