Cannot resolve module 'react-dom' Cannot resolve module 'react-dom' reactjs reactjs

Cannot resolve module 'react-dom'


Issue is react-dom is not installed, when you hit npm -v react-dom, it gives you the version of npm not react-dom version, you can check that by using npm -v or npm -v react-dom both will give you the same result. You are checking the package version incorrectly.

How to install react and react-dom properly?

Use this to install react and react-dom:

npm install react react-dom --save

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.

How to check install package version?

To check all the locally installed packages version:

npm list    

For globally installed packages, use -g also:

npm list -g

To check the version of any specific package, specify the package name also:

npm list PackageNameFor Example =>   npm list react   npm list react-router

After installation your package.json will look like this:

{  "name": "***",  "version": "1.0.0",  "main": "***",  "scripts": {     ....  },  "repository": {     ....  },  "keywords": [],  "author": "",  "dependencies": {    ....    "react": "^15.4.2",          //react    "react-dom": "^15.4.2",      //react-dom     ....  },  "devDependencies": {     ....  }}

Latest version of react-dom is : 15.4.2

Reference: https://www.npmjs.com/package/react-dom


In my case I had an alias in my webpack.config.common.js:

 resolve: {    extensions: ['.js', '.jsx'],    alias: {      'react-dom': '@hot-loader/react-dom',    },  },

I just removed this line:

'react-dom': '@hot-loader/react-dom',

and it was fixed.


I used 'npm update' and that solved my problem.