skip to Main Content

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:codereact-ttt>npm --version
10.9.0


C:codereact-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:UsersmynameAppDataLocalnpm-cache_logs2025-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:UsersddavisAppDataLocalnpm-cache_logs2025-01-06T06_23_44_167Z-debug-0.log

Edit: Changed react version to ^19.0 and it worked with warnings.

2

Answers


  1. What 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 depreciated. 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.

    Login or Signup to reply.
  2. 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).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search