I have been working on integrating KeenSlider into my project by installing it from npm. However, I am encountering an error message that says
Uncaught ReferenceError: KeenSlider is not defined
whenever I try to use the package in my Astro component.
Below is a snippet of my astro file:
---
import KeenSlider from "keen-slider";
---
<div id="carousel" class="keen-slider">
<div class="keen-slider__slide">
<h4>1</h4>
</div>
<div class="keen-slider__slide">
<h4>2</h4>
</div>
</div>
<script lang="js">
var slider = new KeenSlider("#carousel", {
slidesPerView: 1.25,
spacing: 30,
});
</script>
I have also attempted using
import KeenSlider from "keen-slider"
, and import { useKeenSlider } from "keen-slider"
(with and without brackets), but these did not resolve the issue.
I have not made any modifications to my astro.config.mjs
file, as I believe installation via npm and referencing in the component should cover everything with Astro's handling. However, there seems to be a mistake on my end. How can I properly define 'KeenSlider'?