Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot use import statement outside a module using nuxtjs

I am trying to use vue-agile carousel, I can install and get it to run without any issues right after i install it, i am using NUXT, but after restarting my server i keep getting this error and can not find any solution for it

<template>
  <div>
    <agile>
      <div class="slide">
        <img src="/img/img2.jpg" alt="" />
      </div>
      <div class="slide">
        <img src="/img/img1.jpg" alt="" />
      </div>
    </agile>
  </div>
</template>
<script >
import { VueAgile } from "vue-agile";
export default {
  name: "",
  layout: "",
  middleware: [],
  data() {
    return {};
  },
  components: {
    agile: VueAgile,
  },
  
};
</script>

enter image description here

enter image description here

like image 271
CYBERSIX Avatar asked Jun 14 '26 04:06

CYBERSIX


1 Answers

Did you checked the documentation about how to use this plugin in Nuxt instead of a regular Vue?

plugins/vue-agile.js

import Vue from 'vue'
import VueAgile from 'vue-agile'

Vue.use(VueAgile)

nuxt.config.js

export default {
    plugins: ['~/plugins/vue-agile', mode: 'client']
}

To use component without SSR use the client-only component:

<client-only placeholder="Loading...">
    <agile>...</agile>
</client-only>

EDIT: Add Shreerang's suggestion (comment below).

like image 102
Sergio Cerrutti Avatar answered Jun 15 '26 17:06

Sergio Cerrutti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!