Error: Unable to locate 'react/lib/React' in ReactDOM directory

Help! I’ve hit a snag with my React project.

I was coding away when this error popped up out of nowhere:

Failed to compile
../node_modules/react-dom/lib/ReactMount.js
Module not found: Can't resolve 'react/lib/React' in 'C:\Users\Angelin\ecom\node_modules\react-dom\lib'

I’m using a bunch of dependencies like antd, axios, and firebase. My React version is 17.0.1 and I’m running react-scripts 4.0.1.

I’ve tried googling the error but nothing seems to work. Any ideas what might be causing this? Maybe it’s a version mismatch or something weird with my node_modules?

I’m pretty stumped here. Any help would be awesome! Let me know if you need any more info about my setup.

This error often pops up due to version mismatches or corrupted dependencies. First, double-check your package.json to ensure React and ReactDOM versions are compatible (both should be 17.0.1 in your case). If that’s not the issue, try a clean reinstall:

  1. Delete your node_modules folder
  2. Remove package-lock.json
  3. Run ‘npm cache clean --force’
  4. Do a fresh ‘npm install’

If the problem persists, it might be worth checking if any of your other dependencies (antd, axios, firebase) have specific version requirements that could be causing conflicts. You can use ‘npm ls react’ and ‘npm ls react-dom’ to verify installed versions.

Lastly, ensure all your import statements are correct. Sometimes, incorrect imports can lead to these types of errors. Hope this helps!

hey iris85, sounds frustrating! have u tried clearing ur npm cache? sometimes that fixes weird module issues. run ‘npm cache clean --force’ then delete node_modules and package-lock.json. after that, do a fresh ‘npm install’. might sort it out. good luck!