inertia icon indicating copy to clipboard operation
inertia copied to clipboard

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'"

Open tkoop opened this issue 1 year ago • 1 comments

Version:

  • @inertiajs/vue3 version: 1.0.15

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

tkoop avatar Feb 29 '24 19:02 tkoop

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?

craigrileyuk avatar Mar 19 '24 05:03 craigrileyuk

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

reinink avatar May 28 '24 11:05 reinink