Module not found: Can't resolve 'react-dom' in ReactJs

Dung Do Tien Jul 10 2021 232

I have a small project with ReactJS. Everything works well but today I get code from GitLab and builds code I get an error:

ERROR in ./public/src/main.js
Module not found: Error: Cannot resolve module 'react-dom' in C:\DevUp\react-demo\public\src 
@ ./public/src/main.js 19:16-36

My package.json

"name": "component",
  "version": "0.1.0",
  "main": "build/index.js",
  "dependencies": {
    "react-grid-layout": "^0.16.0",
    "react-redux": "^5.0.6",
    "redux": "^3.7.2",
    "semantic-ui-css": "^2.2.12",
    "semantic-ui-react": "^0.75.1"
  },

Thanks for any suggestions.

Have 2 answer(s) found.
  • T

    Thủy Lê Jul 10 2021

    Use this to install the latest version of react and react-dom:

    npm install react react-dom --save

    If you installed it, you can run npm install to update all modules in your package file.

    I hope it works for you.

  • h

    hiep nguyenduc Jul 10 2021

    Maybe the issue it's that your react-dom it's not properly installed.

    try run:

    npm install react react-dom --save

    and after that, check your package.json file, it must include the dependencies of react-dom. For example:

    "dependencies": {
        ....
        "react": "^15.4.2",          //react
        "react-dom": "^15.4.2",      //react-dom
         ....
    },

    It works for me!!

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close