Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work with SvelteKit 1.5.0 #134

Open
dimdenGD opened this issue Mar 3, 2023 · 7 comments
Open

Doesn't work with SvelteKit 1.5.0 #134

dimdenGD opened this issue Mar 3, 2023 · 7 comments

Comments

@dimdenGD
Copy link

dimdenGD commented Mar 3, 2023

I get error in the title when trying to use it like this in SvelteKit 1.5.0:

TypeError: Cannot read properties of undefined (reading 'default')
    at Module.createCarousel [as default] (/node_modules/svelte-carousel/src/components/Carousel/createCarousel.js:23:19)
    at Carousel.svelte:33:70
    at Object.$$render (/node_modules/svelte/internal/index.mjs:1892:22)
    at eval (/src/routes/+page.svelte:52:99)
    at Object.$$render (/node_modules/svelte/internal/index.mjs:1892:22)
    at Object.default (root.svelte:42:40)
    at eval (/src/routes/+layout.svelte:48:32)
    at Object.$$render (/node_modules/svelte/internal/index.mjs:1892:22)
    at root.svelte:41:39
    at $$render (/node_modules/svelte/internal/index.mjs:1892:22)

using code:

<script>
    import Carousel from 'svelte-carousel';
</script>
<div>
    <Carousel>
        <div>test</div>
        <div>test</div>
    </Carousel>
</div>

Versions:
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.5.0",
"svelte": "^3.54.0",
"svelte-carousel": "^1.0.23",
"vite": "^4.0.0"

@MelleNi
Copy link

MelleNi commented Mar 7, 2023

Same issue in Astro

@Jaydeep189
Copy link

Getting th exact same error

@TomixUG
Copy link

TomixUG commented Mar 11, 2023

Same

@dimdenGD dimdenGD changed the title TypeError: Cannot read properties of undefined (reading 'default' Doesn't work with SvelteKit 1.5.0 Mar 12, 2023
@leonbeon
Copy link

I had a slightly different error but also caused by a new sveltekit version, so maybe it will help you too: I used vite-plugin-iso-import as per the svelte docs for client-side only packages (last snippet).

It looks like this:

<script>
	import Carousel from 'svelte-carousel?client';
    // ...
</script>

You can also remove the vite exceptions in your vite.config.js so it looks like this:

import { sveltekit } from '@sveltejs/kit/vite';
import { isoImport } from 'vite-plugin-iso-import'

const config = {
	plugins: [isoImport(), sveltekit()],
};

export default config;

Tested in sveltekit v1.13.0.

@frandevea
Copy link

same issue

@g-roll
Copy link

g-roll commented Jul 5, 2023

With the browser module you can run code client-side only.

<script>
	import { browser } from '$app/environment';
	import Carousel from 'svelte-carousel';

	export let testimonials;
</script>

{#if browser}
	<Carousel>
		{#each testimonials as testimonial}
			...
		{/each}
	</Carousel>
{/if}

Works for me in SvelteKit v1.20.4

@niocncn
Copy link

niocncn commented Aug 2, 2023

same issue on svelte 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants