[Solved] Cannot find module 'react-dom/client' from 'node_modules/@testing-library/react/dist/pure.js'
Problem:
Currently, I am working on a group react project. I cloned the project from GitHub. when I try to run this project to test it I got the following error:
Cannot find module 'react-dom/client' from 'node_modules/@testing-library/react/dist/pure.js'
I deleted the node_modules and reinstalled it but It did not help me. This is my code:
import React from "react";
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import '@testing-library/jest-dom';
and for testing the project, I am using @testing-library/react: 13.0.0
In this article, I am going to write the possible solution to this problem.
Solution:
The problem is you are using the newer version of @testing-library/react. If you downgrade to version 12.0.0 your problem will solve. To install the downgraded version run this:
npm install @testing-library/react@12
Hope this solves your error. If you have any queries comment below