How do I import swiper.js package from node_modules into my main js.file?
Hey guys,
So I downloaded the swiper.js packackge via npm and did exactly what the doc says but it doesnt work?!!? I even tried to import with relative path but it still does not work. So how do I have to import it?!
3 Replies
perhaps try with script?
<script src = ".../../node_modules/swiper/swiper.js"></script>
like adding this to the end of your bodyThanks buddy But I figured it out why it doesnt work. The ‚import swiper from..‘syntax mentions in swiper documentation only works with a bundle (parcel, webpack etc). It doesn’t work with pure vanilla js. I dont know why they don’t mention it . For beginners like me it would be so much helpful. To make it work without a bundler I must import the .mjs file which stands for EcmaScript modules.
k gotcha
gd to know u figured it out
gd luck 🫂