最近reactでnpm installするとこんな感じのエラーが表示されるので、対策をまとめました。

$ npm install @apollo/client graphql apollo-upload-client

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR!   peerOptional react@"^16.8.0 || ^17.0.0" from @apollo/client@3.3.11
npm ERR!   node_modules/@apollo/client
npm ERR!     @apollo/client@"^3.3.8" from the root project
npm ERR!     @apollo/client@"^3.2.5" from apollo-upload-client@14.1.3
npm ERR!     node_modules/apollo-upload-client
npm ERR!       apollo-upload-client@"*" from the root project
npm ERR!   19 more (@storybook/addon-actions, ...)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.4" from react-inspector@5.1.0
npm ERR! node_modules/@storybook/addon-actions/node_modules/react-inspector
npm ERR!   react-inspector@"^5.0.1" from @storybook/addon-actions@6.1.20
npm ERR!   node_modules/@storybook/addon-actions
npm ERR!     dev @storybook/addon-actions@"^6.1.18" from the root project
npm ERR!     1 more (@storybook/addon-essentials)
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 ERR! 
npm ERR! ~/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!    ~/.npm/_logs/2021-03-13T01_36_31_206Z-debug.log

参考

https://stackoverflow.com/questions/64529958/error-when-trying-to-install-react-redux-dependency

対策

一時的な処置な気はするのですが(予想ですけど、なんらかのモジュールで対応されれば表示されなくなるはず)、このように --legacy-peer-deps の引数をつけて実行すれば通りました。

$ npm install @apollo/client graphql apollo-upload-client  --legacy-peer-deps