yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.44k stars 2.73k forks source link

Node module dependency bug #3974

Open Jhays10 opened 7 years ago

Jhays10 commented 7 years ago

Do you want to request a feature or report a bug? Bug

What is the current behavior? The requested package version is being ignored and substituted with a sub-package module in another dependency.

If the current behavior is a bug, please provide the steps to reproduce.

What is the expected behavior? When leaflet-virtual-grid is installed, its leaflet dependency shouldn't be installed, as it's already included previously. This is working correctly in NPM v5. In NPM v5, the node_modules for leaflet-virtual-grid are not installed and it will use the existing leaflet dependency.

Please mention your node.js, yarn and operating system version.

BYK commented 7 years ago

This is weird. I'd expect 1.0.x to not be compatible with ^1.0.0-rc.1 which is what leaflet-virtual-grid lists but semver says otherwise:

> semver.satisfies('1.0.3', '^1.0.0-rc.1')
true

@arcanis any ideas?

BYK commented 7 years ago

@arcanis this also looks similar to #3967

arcanis commented 7 years ago

Well it's the same issue as #3951 - leaflet-virtual-grid is using a dependencies entry instead of a peerDependencies, so they get resolved to two different versions ...

arcanis commented 7 years ago

That being said, as @BYK noticed the hoisting should probably still have worked in this particular case since 1.0.3 is compatible with ^1.0.0-rc.1. Hm.

(I still advise you to open an issue on leaflet-virtual-grid to fix this peerDependencies thing, tho - their dependencies are currently unsafe and subject to breakages)

Jhays10 commented 7 years ago

Unfortunately it looks as if that project is not maintained anymore. In our project, we don't actually require leaflet-virtual-grid to be installed, it's actually a dependency through esri-leaflet which we do require. But it's certainly worth a shot of creating an issue over there as well.