자바스크립트로 작성한 리액트 앱을 타입스크립트로 마이그레이션 작업하는 과정에서 redux-actions를 찾을 수 없다는 에러가 발생했다.
이 에러를 해결하기 위해 @types/redux-actions
패키지를 설치하려 했는데, 다음과 같이 종속성 에러가 발생했다.
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.1.3
npm ERR! node_modules/typescript
npm ERR! dev typescript@"^5.1.3" from the root project
npm ERR! peer typescript@">= 2.7" from fork-ts-checker-webpack-plugin@6.5.3
npm ERR! node_modules/fork-ts-checker-webpack-plugin
npm ERR! fork-ts-checker-webpack-plugin@"^6.5.0" from react-dev-utils@12.0.1
npm ERR! node_modules/react-dev-utils
npm ERR! react-dev-utils@"^12.0.1" from react-scripts@5.0.1
npm ERR! node_modules/react-scripts
npm ERR! react-scripts@"5.0.1" from the root project
npm ERR! 1 more (tsutils)
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.1" 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.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.
그래서 chatgpt한테 물어봤더니
react-scripts@5.0.1을 설치하기 위해서는 typescript@^3.2.1 || ^4 버전이 필요한데,
npm ERR! peerOptional typescript@"^3.2.1 || ^4" from react-scripts@5.0.1
현재 typescript@4.9.5가 설치되어 있어서 종속성 충돌이 발생한다고 했다.
npm ERR! Conflicting peer dependency: typescript@4.9.5
그래서 typescript 버전을 다운그레이드 시킨 다음, 다시 설치했더니 에러가 해결되었다.