mapbox-gl-directions icon indicating copy to clipboard operation
mapbox-gl-directions copied to clipboard

Incorrect mapbox-gl peer dependency range (npm7 workspaces)

Open dschnare opened this issue 3 years ago • 13 comments

{
  "peerDependencies": {
    "mapbox-gl": "^0.41.0 <2.0.0"
  }
}

This semver range computes to >=0.41.0 <0.42.0-0 <2.0.0. This range can only be satisfied with mapbox-gl versions >= 0.41.0 < 0.42.0.

This becomes a problem when using npm 7.x and workspaces.

Suggested fix is to change the semver range for the mapbox-gl peer dependency to 0.41.0 <2.0.0, this will allow mapbox-gl any version below 2.0.0 and above or equal to 0.41.0 to meet the peer dependency which I believe was the original intention.

dschnare avatar Oct 29 '20 17:10 dschnare

After review of my suggested change, I believe the range should be this >=0.41.0 <2.0.0.

dschnare avatar Oct 30 '20 13:10 dschnare

I have the same issue, let me know if there is a "hacky" solution for the time being

chingiz19 avatar Mar 18 '21 16:03 chingiz19

This wasn't a problem for us until our CI/CD pipeline upgraded to Node 16.15.1 & npm 8.11.0 now we see this error during npm install:

npm ERR! While resolving: @mapbox/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/mapbox-gl
npm ERR!   mapbox-gl@"^1.13.2" from the root project
npm ERR!   peer mapbox-gl@">=0.32.1 <2.0.0" from @mapbox/[email protected]
npm ERR!   node_modules/@mapbox/mapbox-gl-supported
npm ERR!     @mapbox/mapbox-gl-supported@"^1.5.0" from [email protected]
npm ERR!   1 more (ngx-mapbox-gl)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer mapbox-gl@"^0.41.0 <2.0.0" from @mapbox/[email protected]
npm ERR! node_modules/@mapbox/mapbox-gl-directions
npm ERR!   @mapbox/mapbox-gl-directions@"^4.1.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/mapbox-gl
npm ERR!   peer mapbox-gl@"^0.41.0 <2.0.0" from @mapbox/[email protected]
npm ERR!   node_modules/@mapbox/mapbox-gl-directions
npm ERR!     @mapbox/mapbox-gl-directions@"^4.1.0" from the root project

sezf-opscentral avatar Jun 09 '22 01:06 sezf-opscentral

Example on mapbox website shows mapbox-gl 2.8.2 working together with mapbox-gl-directions 4.1.0

A work-around solution for when you use NPM version > 7 is to run npm install with the --legacy-peer-deps flag It seems that the new NPM version has a stricter policy when it comes to peer dependencies.

dennisvd avatar Jun 26 '22 11:06 dennisvd

Still having this problem today:

$ npm i @mapbox/mapbox-gl-directions
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/mapbox-gl
npm ERR!   mapbox-gl@"^2.10.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer mapbox-gl@"^0.41.0 <2.0.0" from @mapbox/[email protected]
npm ERR! node_modules/@mapbox/mapbox-gl-directions
npm ERR!   @mapbox/mapbox-gl-directions@"*" 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! See C:\Users\ryanr\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ryanr\AppData\Local\npm-cache\_logs\2022-10-31T21_13_30_240Z-debug-0.log

Does install with --legacy-peer-deps but this is almost certainly less than ideal. It's also worth noting that there is still nothing mentioned about this issue in the navigation docs, or on npmjs.com, or general Mapbox docs, as far as I could find. Maybe updates are needed?

These places would be good places to bring attention to the issue: Docs NPM

rogadev avatar Oct 31 '22 21:10 rogadev

I spoke too soon. It installs without the above error tree, but doesn't seem to be there when I attempt to import it.

import MapboxDirections from "@mapbox/mapbox-gl-directions";

Cannot find module '@mapbox/mapbox-gl-directions' or its corresponding type declarations.ts(2307)

rogadev avatar Oct 31 '22 22:10 rogadev

Currently, it does install with --legacy-peer-deps but then it throws an error when launching the app.

error - ./node_modules/@mapbox/mapbox-gl-directions/src/controls/inputs.js:6:0
Module not found: Can't resolve 'fs'

Import trace for requested module:
./node_modules/@mapbox/mapbox-gl-directions/src/directions.js
./node_modules/@mapbox/mapbox-gl-directions/src/index.js

Tepepaz avatar Feb 05 '23 15:02 Tepepaz

A recent update to package.json seems to finally address this in the #298 changeset.

Seems like we're now just waiting for them to publish a new version to NPM? cc @chriswhong

kennydurkin avatar Mar 17 '23 17:03 kennydurkin

@chriswhong Any updates on this issue?

collier-watkins avatar Apr 03 '23 16:04 collier-watkins

Any update on this? @rogadev How do you solve this?

snsd0805yoona avatar May 16 '23 19:05 snsd0805yoona

Yep, i also faced with this problem "Cannot find module '@mapbox/mapbox-gl-directions'", any suggestions?

Vlad-Vasinev avatar Jun 01 '23 21:06 Vlad-Vasinev

@chriswhong Could you please tell me if there's a solution, or update upcoming? I would use the navigation package for a school project and the deadline is coming :D

makosdanii avatar Jun 04 '23 17:06 makosdanii

Hello, I'm curious about updates on this issue as well. Thank you! 🙂


Update: I installed successfully with the --legacy-peer-deps flag, but I then also get an fs app error:

Uncaught TypeError: fs.readFileSync is not a function

It seems to come from the inputs.js file:

Screen Shot 2023-09-20 at 9 39 37 PM
let fs = require('fs'); // substack/brfs#39
let tmpl = template(fs.readFileSync(__dirname + '/../templates/inputs.html', 'utf8'));

Update: This worked for me to get around this issue: https://github.com/mapbox/mapbox-gl-directions/issues/261#issuecomment-728927632

gerardo-rodriguez avatar Sep 21 '23 04:09 gerardo-rodriguez