Swiper: Can't resolve './images/index' in '/path-to-project/node_modules/swiper/esm/components/core

Created on 25 Nov 2020  路  4Comments  路  Source: nolimits4web/swiper

It seems like since version 6.0.4 the package has been shipping without some image folder

./node_modules/swiper/esm/components/core/core-class.js
Module not found: Can't resolve './images/index' in '/path-to-project/node_modules/swiper/esm/components/core

This is a (multiple allowed):

  • [x] bug
  • [ ] enhancement
  • [ ] feature-discussion (RFC)
  • Swiper Version: Anything from 6.0.4
  • Platform/Target and Browser Versions: macOS

How to reproduce it

  1. Create a React app by running npx create-react-app slider-test
  2. Install swiper using either npm or yarn yarn add swiper
  3. Replace the contents of App.js with the following code
import React from 'react';
import { Swiper, SwiperSlide } from 'swiper/react';
import SwiperCore from 'swiper';

// Import Swiper styles
import 'swiper/swiper-bundle.css';

export default () => {
  return (
    <Swiper
      spaceBetween={50}
      slidesPerView={3}
      onSlideChange={() => console.log('slide change')}
      onSwiper={(swiper) => console.log(swiper)}
    >
      <SwiperSlide>Slide 1</SwiperSlide>
      <SwiperSlide>Slide 2</SwiperSlide>
      <SwiperSlide>Slide 3</SwiperSlide>
      <SwiperSlide>Slide 4</SwiperSlide>
      ...
    </Swiper>
  );
};
  1. Run yarn start and expect to see the error message in the screen

Thanks for your awesome work! 馃憦

Most helpful comment

It turns out to be the .yarnclean file, which contains a line images by default, if you are using yarn install, it automatically cleans the images folder. Just delete the line.

All 4 comments

I've met the same issue. Weirdly, using npm install works fine, the images folder is there, while yarn does not.

It turns out to be the .yarnclean file, which contains a line images by default, if you are using yarn install, it automatically cleans the images folder. Just delete the line.

Thanks @bruceCzK ! Closing as not related to Swiper

Thanks @bruceCzK !!!!

Was this page helpful?
0 / 5 - 0 ratings