npm installをしたら下記のエラーが出た
% npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-scripts@5.0.1
npm ERR! Found: typescript@5.7.2
npm ERR! node_modules/typescript
npm ERR! dev typescript@"5.7.2" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"^5.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@4.9.5
npm ERR! node_modules/typescript
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"^5.0.0" 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.
this command with --force or --legacy-peer-deps
(--force または --legacy-peer-deps オプションを指定してこのコマンドを実行してください。)
違いは何か
--legacy-peer-deps: npmのバージョン7以降、peer dependenciesの競合があるとインストールが止まるようになりました。--legacy-peer-deps はnpm v6以前の古い挙動に戻すオプションです。競合があってもある程度と無視してインストールしてくれます
--force : 強制インストール。競合だけでなく、あらゆる警告やチェックを無視して強制インストールします。キャッシュも無視して再ダウンロードします。
#対応
npm install --legacy-peer-deps