I've seen few posts related to this type of error. But couldn't resolve in mine.
My package.json:
"react": "~0.14.7",
"webpack": "^1.12.13",
"react-hot-loader": "^3.0.0-beta.6",
.
.
I'm getting following error on webpack:
ERROR in ./public/src/main.js
Module not found: Error: Cannot resolve module 'react-dom' in C:\Users\react-example\public\src
@ ./public/src/main.js 19:16-36
But in the cmd line when I did
npm -v react-dom
I get 3.10.10. react-dom is there. But I wonder why it still gives this error.
When I installed react-dom through npm "npm install react-dom", and run webpack I get following errors:
ERROR in ./~/react-dom/lib/ReactDOMNullInputValuePropHook.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
@ ./~/react-dom/lib/ReactDOMNullInputValuePropHook.js 13:29-72
ERROR in ./~/react-dom/lib/ReactDOMUnknownPropertyHook.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
@ ./~/react-dom/lib/ReactDOMUnknownPropertyHook.js 15:29-72
ERROR in ./~/react-dom/lib/ReactDOMInvalidARIAHook.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
@ ./~/react-dom/lib/ReactDOMInvalidARIAHook.js 14:29-72
ERROR in ./~/react-dom/lib/ReactDebugTool.js
Module not found: Error: Cannot resolve 'file' or 'directory' C:\Users\react-example/node_modules/react/lib/ReactComponentTreeHook in C:\Users\react-example\node_modules\react-dom\lib
@ ./~/react-dom/lib/ReactDebugTool.js 16:29-72
Please help.
Try
rm -rf node_modules && yarn
orrm -rf node_modules && npm install
if you use npm instead of yarn.I used 'npm update' and that solved my problem.
Issue is
react-dom
is not installed, when you hitnpm -v react-dom
, it gives you the version ofnpm
notreact-dom
version, you can check that by usingnpm -v
ornpm -v react-dom
both will give you the same result. You are checking the package version incorrectly.Use this to install react and react-dom:
After that, you can check your
package.json
file, if react and react-dom has been installed correctly, you will find an entry for that.To check all the locally installed packages version:
For globally installed packages, use -g also:
To check the version of any specific package, specify the package name also:
After installation your
package.json
will look like this:Latest version of
react-dom
is : 15.4.2Reference: https://www.npmjs.com/package/react-dom
For anybody reading this that wasn't able to figure it out. I had the same issue which I ended up resolving by installing the "react-router" package which is simply running the following command
npm i react-router-dom --save
for a browser app.npm i react-router-native
for a native app.My particular issue for getting this error:
To fix this issue, I had to unzip the folder before installing.