facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.43k stars 26.76k forks source link

Peer dependency issue happens when npm install #13259

Open betimer opened 1 year ago

betimer commented 1 year ago
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.6

Describe the bug

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.6
npm ERR! node_modules/typescript
npm ERR!   typescript@"^5.1.6" 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.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! C:\Users\betim\AppData\Local\npm-cache\_logs\2023-06-29T04_51_46_119Z-eresolve-report.txt

Did you try recovering your dependencies?

Yes. Have removed package-lock.json and node_modules, then reinstall, the issue is the same.

Environment

OS: Windows 11 Node: 18.16.1 Npm: 9.7.2

Steps to reproduce

npm install

Expected behavior

No error

Actual behavior

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.6
atlowl commented 1 year ago

Possible duplicate of #13080

dannechypor commented 6 months ago

It looks like react-scripts should actually be using TypeScript 5 but isn’t at the moment. Make sure to manually update your TypeScript to version 5 to avoid any hiccups. Also, take a moment to check your Node.js version and update it if necessary. To work around any peer dependency issues, you can run npm install --legacy-peer-deps in your project. This should help get everything in sync.