The npm community forum has been discontinued.
To discuss usage of npm, visit the GitHub Support Community.
Install aliased peer dependency
I’ve been facing an issue with dependencies. I’m using
react-leaflet in my project but turns out I need two different components in two different versions.
I’ll explain further:
One part of my application needs
However, the rest of my code needs
This wasn’t a problem since I used this command to install multiple versions as aliased packages:
npm install leaflet react-leaflet leaflet-legacy@npm:firstname.lastname@example.org react-leaflet-legacy@npm:email@example.com
Everything works fine until I get our well known warning message:
npm WARN firstname.lastname@example.org requires a peer of leaflet@^0.7.0 but none is installed. You must install peer dependencies yourself.
So how can I use both versions in my code but also solve peer dependency issues?
Thanks in advance!
A (heavy) option would be to split out the code needing the old version into a separate package so you can specify the required dependencies independently from your main package?
It could work, but the project will definitely become unreadable at some point, since the main package will also include the independent package.
I was thinking of going back to npm2 where dependencies are installed and duplicated inside the
node_modules folder; but I can’t force any other programmer to run my application only with npm2.