mapcentia / vidi

Vidi – a modern take on browser GIS. It is the front-end client for GC2.
https://www.osgeo.org/projects/gc2-vidi/
GNU Affero General Public License v3.0
44 stars 25 forks source link

npm: Could not resolve dependency: peer leaflet@"^1.9.3" #304

Open velle opened 5 days ago

velle commented 5 days ago

The commands below are run in a clean Ubuntu 22.04 container with npm 9.2.0.

root@79f1aecaf65b:/# git clone https://github.com/mapcentia/vidi.git
root@79f1aecaf65b:/# cd vidi
root@79f1aecaf65b:/vidi# npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @maplibre/maplibre-gl-leaflet@0.0.22
npm ERR! Found: leaflet@1.7.1
npm ERR! node_modules/leaflet
npm ERR!   peer leaflet@"1.7.1" from leaflet.glify@3.2.0
npm ERR!   node_modules/leaflet.glify
npm ERR!     leaflet.glify@"^3.2.0" from the root project
npm ERR!   peer leaflet@"^1.3.1" from leaflet.markercluster@1.5.3
npm ERR!   node_modules/leaflet.markercluster
npm ERR!     leaflet.markercluster@"^1.4.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer leaflet@"^1.9.3" from @maplibre/maplibre-gl-leaflet@0.0.22
npm ERR! node_modules/@maplibre/maplibre-gl-leaflet
npm ERR!   @maplibre/maplibre-gl-leaflet@"^0.0.22" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: leaflet@1.9.4
npm ERR! node_modules/leaflet
npm ERR!   peer leaflet@"^1.9.3" from @maplibre/maplibre-gl-leaflet@0.0.22
npm ERR!   node_modules/@maplibre/maplibre-gl-leaflet
npm ERR!     @maplibre/maplibre-gl-leaflet@"^0.0.22" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry`
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! 
npm ERR! For a full report see:
npm ERR! /root/.npm/_logs/2024-11-20T18_55_30_252Z-eresolve-report.txt

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2024-11-20T18_55_30_252Z-debug-0.log
velle commented 5 days ago

I don't quite understand what the actual problem is, if there is one. But this workaround worked for me (with npm 9.2.0):

npm install --legacy-peer-deps

And I think npm versions 4-6 don't raise these problems (source).

mapcentia commented 4 days ago

It's leaflet.glify which has a specific version of leaflet as dependency. Luckily the latest glify has leaflet@1.9.4 as dependency, which satisfies other dependent modules. This will be fixed is next release. Just use --legacy-peer-deps or update leaflet.glify