Problem with adding new packages

Someone could explain me because it is so difficult to add some packages?
I need to add Swiper pkg to my Sage 9.0.9 installation but I need to spend half day to understand how to import it, and I haven’t succeeded yet.
I’m definitely not the most experienced person but every time you have to argue with something new, as soon as you seem to understand how it works. Where am I wrong? What do I not know and do I need to understand better?


I’ve checked right now this slider and works fine.

  1. yarn add swiper
  2. in Main.scss add
// Swiper
@import "~swiper/swiper-bundle.css";
  1. In common.js at the top import swiper
// import Swiper JS
import Swiper from 'swiper';
  1. In common js, in init(){ … }; function add
// test
const test = new Swiper('.swiper-container');
  1. In your template somewhere add html structure for your slider
<div class="swiper-container">
  <div class="swiper-wrapper">
      <div class="swiper-slide">
          Slide 1
      <div class="swiper-slide">
          Slide 2
      <div class="swiper-slide">
          Slide 3

That’s all for minimal setup.

This plugin have a lot of options, so please read documentation

Thank you Jacek!

I had entered import Swiper from ‘swiper’ into main.js. Why I need to insert into common.js? ( I never find an answer to this type of question)

Now I have followed your instructions but when I “yarn build” , it ask me to install
npm install -save swiper

I do it

Then yarn build&&start and now ask me to install other packages that I have yet installed and used:
npm install --save @fortawesome/fontawesome-svg-core @fortawesome/free-brands-svg-icons owl.carousel


But I do it.

Then yarn build and:

@ multi ./scripts/main.js ./styles/main.scss

error in ./resources/assets/styles/main.scss

Module build failed: ModuleBuildError: Module build failed:
File to import not found or unreadable: ~hamburgers/_sass/hamburgers/hambu
in S:\www\tmsite\wp-content\themes\xxxxxxxxxxxx\resources\assets\styles\ma
in.scss (line 2, column 1)
at runLoaders (S:\www\tmsite\wp-content\themes\xxxxxxxxxx\node_modules\web
at S:\www\tmsite\wp-content\themes\xxxxxxx\node_modules\loader-runner\l
at S:\www\tmsite\wp-content\themes\xxxxxx\node_modules\loader-runner\l
at context.callback (S:\www\tmsite\wp-content\themes\xxxxxxxxxxxx\node_modul
at Object.asyncSassJobQueue.push [as callback] (S:\www\tmsite\wp-content\the
at Object.done [as callback] (S:\www\tmsite\wp-content\themes\xxxxxxxxxxx\n
at options.error (S:\www\tmsite\wp-content\themes\xxxxxxxxxxxxx\node_modules

And now?
…very heartbroken

After that, I try to npm install and now everything works.

I have no words…
thank you for your patience…

Good job. In the future don’t mix npm and yarn in the same project to prevent conflict lock files.

Thank you
I need to clear me difference between yarn and npm and when to use one or other.
Thank you again…

This topic was automatically closed after 42 days. New replies are no longer allowed.