reactjsnpmcreate-react-appreact-scripts

Trying to do a React tutorial and getting ERESOLVE "unable to resolve dependency tree"


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.

  1. What is the meaning of this error/why does it happen?
  2. 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: react.dev@0.0.0
npm error Found: react@19.0.0-rc-3edc000d-20240926
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 react-scripts@5.0.1
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 npm@11.0.0
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.


Solution

  • What is the meaning of this error/why does it happen?

    How do I resolve it (without causing some other problem).

    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.