launchdarkly / react-client-sdk

LaunchDarkly Client-side SDK for React.js
Other
86 stars 68 forks source link

Peer dependencies not automatically resolvable in npm 7 #63

Closed tom-hag closed 3 years ago

tom-hag commented 3 years ago

Describe the bug Currently your docs say:

This version of the LaunchDarkly SDK is compatible with versions 16.3.0 and later of React because it uses React's Context API. However, if you are using the SDK's Hooks API or asyncWithLDProvider, then you must use React version 16.8.0 or later.

Since npm 7 now automatically installs peer dependencies by default I cannot install launchdarkly-react-client-sdk (as recommended in the sdk docs) with react 17.0.1.

This can be fixed by adding the --legacy-peer-deps flag to the npm i command when using npm 7.

This issue is not present when using npm 6 since it behaves as though --legacy-peer-deps were on by default.

To reproduce

Expected behavior launchdarkly-react-client-sdk should install for react 17.0.1 as suggested is possible in the docs.

Logs This is the error log of npm i --save launchdarkly-react-client-sdk

npm ERR! While resolving: my-app@1.0.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.6.3" from launchdarkly-react-client-sdk@2.22.1
npm ERR! node_modules/launchdarkly-react-client-sdk
npm ERR!   launchdarkly-react-client-sdk@"*" 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.

SDK version launchdarkly-react-client-sdk@2.22.1

Language version, developer tools

OS/platform macOS Catalina 10.15.7

edit: I've just noticed https://github.com/launchdarkly/react-client-sdk/pull/61

bwoskow-ld commented 3 years ago

Hi @tom-hag , I do believe this to be a duplicate of #61 as you later noticed. That's what your log output suggests. I'm going to close this issue in favor of that one.

Cheers, @bwoskow-ld

bwoskow-ld commented 3 years ago

This is resolved in 2.22.2.