npm install
をしていたらエラーが発生しました。
PS E:\workspace\Python\tmp\front-back-end\frontend> npm install react-query
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: frontend@8.19.4
npm ERR! Found: react@19.1.0
npm ERR! node_modules/react
npm ERR! react@"^19.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" from react-query@3.39.3
npm ERR! node_modules/react-query
npm ERR! react-query@"*" 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.
npm audit fix --force
やrm -rf node_modules package-lock.json
, npm cache clean --force
をしても全く直りませんでした。
原因
react-scripts
が悪さをしてました。
react-scriptsを使っているとreact-scriptsのバージョンが古すぎて他のパッケージと競合が起きる問題が発生しました
create-react-app がどうやらメンテされなくなったようで react-script が邪魔をして
TypeScript を5以降にバージョンアップできなくなりました。
https://zenn.dev/xronotech/articles/11e671bf0315e7
package.json
からreact-scripts
を外してnpm install
したところ、うまくいきました。