inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.3k stars 423 forks source link

When I try to import @inertiajs/vue, I get error "Uncaught SyntaxError: The requested module '/node_modules/deepmerge/dist/cjs.js?v=51e75926' does not provide an export named 'default'" #1814

Closed tkoop closed 4 months ago

tkoop commented 7 months ago

Version:

Describe the problem:

In my main.js page, I have this line: import { createInertiaApp } from '/node_modules/@inertiajs/vue3'

But when it runs in a browser, the browser says: Uncaught SyntaxError: The requested module '/node_modules/deepmerge/dist/cjs.js?v=51e75926' does not provide an export named 'default'

Steps to reproduce:

Install Laravel and Vite and Inertia.

In index.blade.php: @vite('/resources/views/pages/main.js')

In that main.js file: import { createApp, h } from '/node_modules/vue' import { createInertiaApp } from '/node_modules/@inertiajs/vue3'

The "vue" file gets imported, but I can't import @inertiajs/vue3, becaues the browser throws that error.

I am not including deepmerge in my package.json, but package-lock.json mentions node_modules/deepmerge version 4.3.1

craigrileyuk commented 6 months ago

Why are you trying to import using the absolute path anyway?

NodeJS automatically resolves imports based on the package name using the best available location. You're probably breaking the logic by trying to force it to use a specific location.

What's wrong with:

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

as used in every single project in existence?

reinink commented 4 months ago

Closing this one because we haven't heard anything back.