birdofpreyru / react-native-fs

File system access for React Native
https://dr.pogodin.studio/docs/react-native-file-system
Other
151 stars 11 forks source link

Correct `"react-native-windows: "*"` peer dep #66

Open besdar opened 2 weeks ago

besdar commented 2 weeks ago

Steps to reproduce:

1)

npx @react-native-community/cli@latest init MyProject --version 0.74.5

2)

npm install --save @dr.pogodin/react-native-fs@2.27.1

Result:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: MyProject@0.0.1
npm ERR! Found: react-native@0.74.5
npm ERR! node_modules/react-native
npm ERR!   react-native@"0.74.5" from the root project
npm ERR!   peer react-native@"*" from @dr.pogodin/react-native-fs@2.27.1
npm ERR!   node_modules/@dr.pogodin/react-native-fs
npm ERR!     @dr.pogodin/react-native-fs@"2.27.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react-native@"^0.75.1" from react-native-windows@0.75.0
npm ERR! node_modules/react-native-windows
npm ERR!   peer react-native-windows@"*" from @dr.pogodin/react-native-fs@2.27.1
npm ERR!   node_modules/@dr.pogodin/react-native-fs
npm ERR!     @dr.pogodin/react-native-fs@"2.27.1" 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.

checked on clean Fedora 40 installation, nodejs 20.12.2, npm 10.5.0

birdofpreyru commented 2 weeks ago
  1. The work on this library does not generate any significant revenue for me, thus I only support the latest version of this library and React Native.
  2. The error message clearly tells the problem is that conflicting RN versions have been demanded by different dependencies of your project, in particular react-native-windows@0.75.0 requires react-native@0.75, while your project requires RN v0.74.5. I guess, you just need to pin RN windows to 0.74.x to make it work.
besdar commented 1 week ago

@birdofpreyru thank you for your reply. Ok, I understand that you only support the latest version of the library, no problem.

About the second point: Yes, sorry for taking your time. I don't have a react-native-windows dependency in my project, and it seems that since your library's package.json has a peerDependency "react-native-windows: "*", it causes npm to download the latest available package, which is now 0.75.X, and then it conflicts with my older versions of RN. Installing your package with the --legacy-peer-deps flag solves the problem.

birdofpreyru commented 1 week ago

Ok, I guess going forward "react-native-windows: "*" in package.json should be changed to "react-native-windows: "0.75", or whatever the matching version of RN is.