Could not resolve dependency peer react@"^16.12.0" from pullstate@1.20.1
pSnehanshu opened this issue · comments
This is the error I get after npm install pullstate
in a create-react-app project
code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app@0.1.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.12.0" from pullstate@1.20.1
npm ERR! node_modules/pullstate
npm ERR! pullstate@"1.20.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.
Link to a related Stackoverflow question
Hi @pSnehanshu ,
This is unfortunately due to NPM version 7 being way more strict about peer dependency mismatches.
To get the old behaviour, run npm install
with --legacy-peer-deps
, as they say in the error message.
I'm not really sure how to solve this- as we don't want to throw errors for people who are using React ^16.12.0
- but there's no way for me to say that pullstate is also compatible with ^17.0.1
... NPM and package.json
is rather limited in this regard and its kinda silly because people are obviously going to run into loads of these errors- unless I'm mistaken and missing something.
Actually - I may have been mistaken.
I might be able to solve this with the following:
"peerDependencies": {
"react": "^16.12.0 || ^17.0.0"
}
Why define peer dependancy at all?
Because React is a peer dependency of Pullstate, is it not important to define that? I think for now, its better to have it than not- as it does provide information to tooling and also just for people who use various web apps to tell them about libraries and what is required / size considerations. React is required for Pullstate to work, so its good to have it there.
You can check out version 1.21.0
now @pSnehanshu . I think it should fix this issue.
Can't install with React 18.1.0
LOL! I have been facing similar issues with multiple packages. Every time there's a major React version, a lot of things break.
@lostpebble Thank you for upgrading your package to support React 17. I didn't thank you then, I don't know why, but I am thanking you now.
Have you guys tried the latest version? I did update the peer dependencies for React 18.
@lostpebble Thank you for upgrading your package to support React 17. I didn't thank you then, I don't know why, but I am thanking you now.
Hahah, no stress. You're welcome!