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?!
No description
No description
No description
No description
No description
3 Replies
glutonium
glutonium14mo ago
perhaps try with script? <script src = ".../../node_modules/swiper/swiper.js"></script> like adding this to the end of your body
共産主義のト二イ
Thanks 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.
glutonium
glutonium14mo ago
k gotcha gd to know u figured it out gd luck 🫂
Want results from more Discord servers?
Add your server