swiper icon indicating copy to clipboard operation
swiper copied to clipboard

Cannot find module 'swiper/bundle' or its corresponding type declarations.

Open spacecat opened this issue 3 years ago • 3 comments

I'm following the following tutorial: https://swiperjs.com/get-started

I have a simple TypeScript application with the following files:

  • index.ts
  • tsconfig.json
  • package.json
  1. I created a new package.json using: npm init -y
  2. I installed TypeScript: npm i -D typescript
  3. I create a new tsconfig.json using: npx tsc --init
  4. I installed swiper using: npm i swiper
  5. I added import Swiper from 'swiper'; and import 'swiper/css'; to my index.ts as per the 1st example from https://swiperjs.com/get-started => no complains.
  6. I deleted everything in index.ts.
  7. I added import Swiper, { Navigation, Pagination } from 'swiper';, import 'swiper/css';, import 'swiper/css/navigation';, and import 'swiper/css/pagination'; to my index.ts as per the 2nd example from https://swiperjs.com/get-started => no complains.
  8. I deleted everything in index.ts.
  9. I added import Swiper from 'swiper/bundle'; and import 'swiper/css/bundle'; to my index.ts as per the 3rd example from https://swiperjs.com/get-started => 💥BOOM!💥 Cannot find module 'swiper/bundle' or its corresponding type declarations.

Demo: https://github.com/spacecat/swiper-cannot-find-module

Questions:

  1. Why am I getting the Cannot find module 'swiper/bundle' or its corresponding type declarations. error?
  2. How do I fix it?

Thanks!

spacecat avatar Aug 10 '22 16:08 spacecat

Hello @spacecat. Please provide a online reproduction by codesandbox or a minimal GitHub repository. You can fork one of our demos in codesandbox to get start. Issues labeled by missing demo will be closed if no activities in 3 days.

github-actions[bot] avatar Aug 10 '22 16:08 github-actions[bot]

@nolimits4web I've added the reproduction demo.

spacecat avatar Aug 10 '22 17:08 spacecat

I've added the following for now:

// @ts-ignore
import Swiper from 'swiper/bundle';

spacecat avatar Aug 15 '22 09:08 spacecat

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 21 '23 23:05 stale[bot]