Skip to content

npm install fails because restrictive react semver #578

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 4 tasks
wilson0x4d opened this issue Apr 3, 2021 · 3 comments · Fixed by #579
Closed
2 of 4 tasks

npm install fails because restrictive react semver #578

wilson0x4d opened this issue Apr 3, 2021 · 3 comments · Fixed by #579

Comments

@wilson0x4d
Copy link

wilson0x4d commented Apr 3, 2021

Current behavior

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/react
npm ERR!   react@"^16.14.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"~16.8.6 || ~16.9.0 || ~16.11.0 || ~16.13.1 || ~17.0.1" from @react-native-async-storage/[email protected]
npm ERR! node_modules/@react-native-async-storage/async-storage
npm ERR!   @react-native-async-storage/async-storage@"~1.13.4" from the root project
npm ERR! 

Expected behavior

successful package restore for all ^16.x.x releases.

Repro steps

- load/create any react project targeting react ^16.
- update to latest packages, causing react to upgrade to ^16.14.0 (latest v16 release)
- attempt to install @react-native-async-storage/async-storage 
! install fails because peerDependencies semver cosntraints of async-storage

To simulate a pre-existing project which was working fine until recently:

- init a new application with package.json
- edit package.json to specify react ^16.14.0
- edit package.json to specify @react-native-async-storage/async-storage ^1.13.4
- from cli, attempt `npm install`
! install fails because peerDependencies semver constraints of async-storage

Environment

  • Platforms tested:
    • Android
    • iOS
    • macOS
    • Windows
  • AsyncStorage version: multiple.
  • Expo version: 4
  • Environment:
    npm install is failing.
  • Logs/Errors that may be relevant:

Please consider the following suggested peer deps:

  "peerDependencies": {
    "react": "^16.8.6 || ~17.0.1",
    "react-native": "^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63.2 || ^0.64.0 || 1000.0.0"
  },
  "peerDependencies": {
    "react": "~16.8.6 || ~16.9.0 || ~16.11.0 || ~16.13.1 || ~16.14.0 || ~17.0.1",
    "react-native": "^0.60.6 || ^0.61.5 || ^0.62.2 || ^0.63.2 || ^0.64.0 || 1000.0.0"
  },

I believe for react it makes more sense to target the major version for compatibility, ie. all releases of v16 should be compatible from a downstream perspective, and a semver constraint of ^16.8.6 should allow every v16 release from 16.8 up to but not including v17.0.0 or beyond. It would also be convenient if the same approach was taken for v17.x -- but I'm only concerned about not being forced to upgrade non-deprecated versions of react to use this package.

Thanks!

@tido64
Copy link
Member

tido64 commented Apr 3, 2021

Every version of react-native is tied to a specific version of react. Using any other version is not supported and may cause issues. For instance, using 16.9 with 0.60 used to break debug builds. I would recommend you stick to the supported versions where possible.

That said, AsyncStorage doesn't really depend on react so we can remove it.

@wilson0x4d
Copy link
Author

understood, and confirmed.. digging deeper it appears the last upgrade of our packages was done using a version of npm that has different behaviors, i found several conflicts in our source tree (for example, our react and react-native versions are in conflict, expo-three and three, etc.)

i'm able to work around the issue with cli flags to npm:

npm install --legacy-peer-deps

..but it looks like we'll still need to force upgrade/downgrade packages and run regression tests. fun.

Also, thanks for the feedback! 💯

@krizzu
Copy link
Member

krizzu commented Apr 6, 2021

🎉 This issue has been resolved in version 1.15.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@krizzu krizzu added the released label Apr 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants