ismail9k / vue3-carousel

Vue 3 carousel component
https://ismail9k.github.io/vue3-carousel/
MIT License
722 stars 172 forks source link

Getting "Cannot read properties of undefined (reading 'defineComponent')" error after update to v0.3.3 #378

Open acrolink opened 4 months ago

acrolink commented 4 months ago

All was working fine, after moving from 0.3.1 to 0.3.3 I get:

TypeError: Cannot read properties of undefined (reading 'defineComponent')
    at file:///srv/nuxt/my-app/node_modules/.pnpm/vue3-carousel@0.3.3_vue@3.4.15/node_modules/vue3-carousel/dist/carousel.js:280:27
    at file:///srv/nuxt/my-app/node_modules/.pnpm/vue3-carousel@0.3.3_vue@3.4.15/node_modules/vue3-carousel/dist/carousel.js:9:78
    at file:///srv/nuxt/my-app/node_modules/.pnpm/vue3-carousel@0.3.3_vue@3.4.15/node_modules/vue3-carousel/dist/carousel.js:10:3
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async ViteNodeRunner.interopedImport (file:///srv/nuxt/my-app/node_modules/.pnpm/vite-node@1.6.0_sass@1.70.0_stylus@0.63.0/node_modules/vite-node/dist/client.mjs:383:28)
    at async ViteNodeRunner.directRequest (file:///srv/nuxt/my-app/node_modules/.pnpm/vite-node@1.6.0_sass@1.70.0_stylus@0.63.0/node_modules/vite-node/dist/client.mjs:253:24)
    at async ViteNodeRunner.cachedRequest (file:///srv/nuxt/my-app/node_modules/.pnpm/vite-node@1.6.0_sass@1.70.0_stylus@0.63.0/node_modules/vite-node/dist/client.mjs:189:14)
    at async ViteNodeRunner.dependencyRequest (file:///srv/nuxt/my-app/node_modules/.pnpm/vite-node@1.6.0_sass@1.70.0_stylus@0.63.0/node_modules/vite-node/dist/client.mjs:233:12)

Related code:

<script>
import { defineComponent}  from 'vue'
import { Carousel, Slide } from 'vue3-carousel'
import 'vue3-carousel/dist/carousel.css'

export default defineComponent({

  handleInit() {
    console.log('created')

  },

  name: 'Gallery',
  components: {
    Carousel,
    Slide,
  },

  mounted() {

  },

  data: () => ({
    currentSlide: 0,
  }),

  methods: {
    slideTo(val) {
      this.currentSlide = val
    },
  },
})

</script>
ke11 commented 4 months ago

try replace with import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel/dist/carousel.es.js'

acrolink commented 4 months ago

@ke11 Your suggestion works, thanks.

RomuloNavas commented 4 months ago

I have the same issue with the package v0.3.3. I tried your solution but it still doesn't work for my Nuxt app.

Temporary I decided to downgrade to v0.3.1.

Nicolas-Nmedia commented 3 months ago

If it can help, the error only shows up in SSR mode, it disappears as soon as I disable SSR (and your workaround works, thanks!).

vedmant commented 2 months ago

I have the same issue


acrolink commented 2 months ago

I have the same issue


  • Operating System: Darwin
  • Node Version: v20.12.2
  • Nuxt Version: 3.11.2
  • CLI Version: 3.11.1
  • Nitro Version: 2.9.6
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: devtools, imports, app, pwa, css, components, modules, nitro, vite, sourcemap, runtimeConfig
  • Runtime Modules: @nuxtjs/tailwindcss@6.11.4, @pinia/nuxt@0.4.11, @pinia-plugin-persistedstate/nuxt@1.2.0
  • Build Modules: -

The suggestion of @ke11 works.

vedmant commented 2 months ago

@acrolink It does, but it's a workaround and not a solution.

danbrellis commented 1 month ago

Same issue for me when trying to compile for SSR.

GovarJabbar commented 4 weeks ago

Same issue for me when trying to compile for SSR.

The suggestion of @ke11.