admin管理员组文章数量:1122846
I'm trying to learn React and npm. I'm starting the tutorial here: /learn/tutorial-tic-tac-toe . It also gives the setup to follow if setting up on your own laptop.
package.json :
{
"name": "react.dev",
"version": "0.0.0",
"main": "/src/index.js",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"dependencies": {
"react": "19.0.0-rc-3edc000d-20240926",
"react-dom": "19.0.0-rc-3edc000d-20240926",
"react-scripts": "^5.0.0"
},
"devDependencies": {}
}
However, I get the error below.
- What is the meaning of this error/why does it happen?
- How do I resolve it (without causing some other problem).
`
C:\code\react-ttt>npm --version
10.9.0
C:\code\react-ttt>npm install
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/react
npm error react@"19.0.0-rc-3edc000d-20240926" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@">= 16" from [email protected]
npm error node_modules/react-scripts
npm error react-scripts@"^5.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error C:\Users\myname\AppData\Local\npm-cache\_logs\2025-01-06T06_23_44_167Z-eresolve-report.txt
npm notice
npm notice New major version of npm available! 10.9.0 -> 11.0.0
npm notice Changelog: .0.0
npm notice To update run: npm install -g [email protected]
npm notice
npm error A complete log of this run can be found in: C:\Users\ddavis\AppData\Local\npm-cache\_logs\2025-01-06T06_23_44_167Z-debug-0.log
Edit: Changed react version to ^19.0 and it worked with warnings. Will try to switch to Next.js.
I'm trying to learn React and npm. I'm starting the tutorial here: https://react.dev/learn/tutorial-tic-tac-toe . It also gives the setup to follow if setting up on your own laptop.
package.json :
{
"name": "react.dev",
"version": "0.0.0",
"main": "/src/index.js",
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"dependencies": {
"react": "19.0.0-rc-3edc000d-20240926",
"react-dom": "19.0.0-rc-3edc000d-20240926",
"react-scripts": "^5.0.0"
},
"devDependencies": {}
}
However, I get the error below.
- What is the meaning of this error/why does it happen?
- How do I resolve it (without causing some other problem).
`
C:\code\react-ttt>npm --version
10.9.0
C:\code\react-ttt>npm install
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error node_modules/react
npm error react@"19.0.0-rc-3edc000d-20240926" from the root project
npm error
npm error Could not resolve dependency:
npm error peer react@">= 16" from [email protected]
npm error node_modules/react-scripts
npm error react-scripts@"^5.0.0" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error C:\Users\myname\AppData\Local\npm-cache\_logs\2025-01-06T06_23_44_167Z-eresolve-report.txt
npm notice
npm notice New major version of npm available! 10.9.0 -> 11.0.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.0.0
npm notice To update run: npm install -g [email protected]
npm notice
npm error A complete log of this run can be found in: C:\Users\ddavis\AppData\Local\npm-cache\_logs\2025-01-06T06_23_44_167Z-debug-0.log
Edit: Changed react version to ^19.0 and it worked with warnings. Will try to switch to Next.js.
Share Improve this question edited 20 hours ago Phil 165k25 gold badges259 silver badges267 bronze badges asked yesterday developer981developer981 1118 bronze badges 5 |2 Answers
Reset to default 2What is the meaning of this error/why does it happen?
- there's a dependency issue between react and react-scripts. the react version you're using is
19.0.0-rc
, a release candidate (which might introduce breaking changes). though, react-scripts is asking for a version react version 16 or higher. the current version you're using being a release candidate may be the reason the issue occurs.
How do I resolve it (without causing some other problem).
- Downgrade react
- Or solve the bigger issue which is react-scripts is low key deprecated. React recommends you start react through a framework -- i.e. vite/ nextjs/ etc:
You can definitely use React without a framework—that’s how you’d use React for a part of your page. However, if you’re building a new app or a site fully with React, we recommend using a framework.
1- Your application needs to use some libraries like react, these libraries should be present in the root of your project path in the node_modules folder. After creating your project, you need to run "npm install" on the command line to install all the libraries listed in your project's package.json. After that, if you need to add a new library, you need to install it individually.
2- You need to install node_modules by running "npm install" on the command line (in your project path).
本文标签:
版权声明:本文标题:reactjs - Trying to do a React tutorial and getting ERESOLVE "unable to resolve dependency tree" - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736282591a1926689.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
react-scripts
/ CRA does not support React v19? – Phil Commented 18 hours ago