0

I created an NPM module with an angular library that I use in several projects. Until then, no worries. Except that recently, I added a component that uses swiperJS. I did not understand how to use it well, because when I launch an application that uses my module, even if I never call the component that imports swiper I have an error:

`Error: node_modules/[...]/lib/modules/prime/arg-prime-builder-render/arg-prime-builder-render.module.d.ts:9:21 - error TS2307: Cannot find module 'swiper/angular' or its corresponding type declarations.

9 import * as i8 from "swiper/angular";`

I never use "arg-prime-builder-render.module" in this application

I tried putting and not putting swiper in the peerDependencies of the package.json.

This example is for swiperjs, but I use other external libraries which give me the same problem.

I'm using Angular 13.3 with Node 14.16 and npm 6.14

ArgCedric
  • 32
  • 5

1 Answers1

0

Did you try to install 'swiperJS' same version in your projects, adding it to package.json? This may solve the problem.

  • Yes, but it requires me to install all plugins in each project. Even if my component is not used? – ArgCedric Dec 14 '22 at 12:30
  • 1
    Yes. The best way is to put 'swiperJS' in library peerDependencies and install it on the final project. You can see more information on this post: https://stackoverflow.com/questions/59938107/how-to-add-and-install-peer-dependencies-in-angular-library – Carlos Gómez Rubial Dec 14 '22 at 14:57