Skip to content

Issue while trying to create new project #12279

Closed

Description

@elementkz

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: react-complete-guide@0.1.0
npm ERR! Found: react@18.0.0
npm ERR! node_modules/react
npm ERR! react@"^18.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"<18.0.0" from @testing-library/react@12.1.5
npm ERR! node_modules/@testing-library/react
npm ERR! @testing-library/react@"^12.0.0" 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! See C:\Users\adamr\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\adamr\AppData\Local\npm-cache_logs\2022-04-12T04_05_01_315Z-debug-0.log
npm install --no-audit --save @testing-library/jest-dom@^5.14.1 @testing-library/react@^12.0.0 @testing-library/user-event@^13.2.1 web-vitals@^2.1.0 failed

Activity

  1. elementkz commented on Apr 12, 2022

    @elementkz
    Author

    that's the first time I try to use react so I don't know what any of those errors means

  2. dougmellon commented on Apr 12, 2022

    @dougmellon
  3. danielru15 commented on Apr 12, 2022

    @danielru15

    hola , en un grupo de facebook un usuario me compartio esta solucion:
    abran el proyecto en visual studio y en el index.js remplazarlo por esto:

    importar React desde 'react';
    import { createRoot } desde 'react-dom/client';
    importar './index.css';
    importar la aplicación desde './App';
    const container = document.getElementById('root');
    const root = createRoot(contenedor);
    root.render(
    <React.StrictMode>

    </React.StrictMode>,

    );

    luego puedes ejecutar npm start sin problemas

  4. dhruv-panchal211 commented on Apr 12, 2022

    @dhruv-panchal211

    I found the solution.

    create-react-app is not updating index.js as per the new react V18

    so you need to modify index.js file as follow

    import React from 'react';
    import {createRoot} from 'react-dom/client';
    import './index.css';
    import App from './App';
    // import reportWebVitals from './reportWebVitals';

    const container = document.getElementById('root');
    const root = createRoot(container)

    root.render(
    <React.StrictMode>

    </React.StrictMode>,
    )

    // If you want to start measuring performance in your app, pass a function
    // to log results (for example: reportWebVitals(console.log))
    // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
    // reportWebVitals();

  5. michaelti commented on Apr 12, 2022

    @michaelti

    The ERESOLVE error specifically seems to have been caused by react-testing-library's 12.1.5 release yesterday, which doesn't support React 18.

    It looks like there is a PR already to fix this

  6. morenoisidro commented on Apr 12, 2022

    @morenoisidro

    This should be solved after the recent v5.0.1 release. Try running npx create-react-app again.

  7. arpitghura commented on Apr 13, 2022

    @arpitghura

    I have also encountered with this error yesterday but today the

    npx create-react-app my-app
    

    is not working fine but it now ask to install create-react-app package.

  8. PrabhaShankar-23 commented on Apr 14, 2022

    @PrabhaShankar-23

    This worked out in my case. Beforew creating the app first run this:

    npm config set legacy-peer-deps true

    Then run:

    npx create-react-app my-app

    Explanation:
    The --legacy-peer-deps flag was introduced with v7 as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer dependencies and proceed with the installation anyway. This is how things used to be with NPM v4 through v6.

  9. wulinjie122 commented on Apr 18, 2022

    @wulinjie122

    This worked out in my case. Beforew creating the app first run this:

    npm config set legacy-peer-deps true

    Then run:

    npx create-react-app my-app

    Explanation: The --legacy-peer-deps flag was introduced with v7 as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer dependencies and proceed with the installation anyway. This is how things used to be with NPM v4 through v6.

    Helps me a lot.

  10. Otien0 commented on Apr 26, 2022

    @Otien0

    This worked out in my case. Beforew creating the app first run this:
    npm config set legacy-peer-deps true
    Then run:
    npx create-react-app my-app
    Explanation: The --legacy-peer-deps flag was introduced with v7 as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer dependencies and proceed with the installation anyway. This is how things used to be with NPM v4 through v6.

    Helps me a lot.

    This is the answer I was looking for.

  11. michaelti commented on Apr 26, 2022

    @michaelti

    As far as I understand, the original issue posted by @elementkz was fixed in create-react-app 5.0.1 (release)

    This can probably be closed.

  12. Que0Le commented on Sep 1, 2022

    @Que0Le

    Temporary fix:

    npm config set legacy-peer-deps true
    

    ... before call create-react-app. And in App.tsx file there is a Box got imported twice.

  13. YuvrajSinghJadon commented on Jan 17, 2023

    @YuvrajSinghJadon

    This worked out in my case. Beforew creating the app first run this:

    npm config set legacy-peer-deps true

    Then run:

    npx create-react-app my-app

    Explanation:
    The --legacy-peer-deps flag was introduced with v7 as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer dependencies and proceed with the installation anyway. This is how things used to be with NPM v4 through v6.

    This worked for me thanks

  14. dawit-melka commented on Sep 16, 2023

    @dawit-melka

    I also faced the same issue and I simply solved it by reinstalling the latest version of node.

  15. elementkz commented on Sep 17, 2023

    @elementkz
    Author

    I also faced the same issue and I simply solved it by reinstalling the latest version of node.

    Hi, I posted it in april last year.
    It was a new update that came out the same day, it was fixed I think, and should be closed, sorry for forgetting

  16. shubham1811 commented on Dec 23, 2024

    @shubham1811

    This worked out in my case. Beforew creating the app first run this:

    npm config set legacy-peer-deps true

    Then run:

    npx create-react-app my-app

    Explanation: The --legacy-peer-deps flag was introduced with v7 as a way to bypass peerDependency auto-installation; it tells NPM to ignore peer dependencies and proceed with the installation anyway. This is how things used to be with NPM v4 through v6.

    This worked for me thanks

    It worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions