Unable to allow the module to respond

I have seen several posts related to this type of error. But I could not decide in mine.

My package.json:

"react": "~0.14.7", "webpack": "^1.12.13", "react-hot-loader": "^3.0.0-beta.6", . . 

I get the following error in 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. reacts. But I wonder why he still gives this error.

When I installed the reaction via npm "npm install react-dom" and started webpack, I get the 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.

+21
source share
9 answers

The react-dom problem is not fixed when you press npm -v react-dom , it gives the version version of npm not react-dom , you can verify that with npm -v or npm -v react-dom you will issue the same result. You are not checking the package version correctly.

How to set the reaction and reaction?

Use this to set the reaction and response:

 npm install react react-dom --save 

After that, you can check your package.json file, if the reaction and reaction were installed correctly, you will find an entry for this.

How to check the installation package version?

To check all versions of locally installed packages:

 npm list 

For public packages, use -g as well:

 npm list -g 

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

 npm list PackageName For 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 react-dom version: 15.4.2

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

+32
source

For everyone who reads this, he could not understand it. I had the same problem that I ran into a solution by installing the "response-router" package, which simply runs the following command

npm i react-router-dom --save for the browser.

npm i react-router-native for native application.

+4
source

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

+2
source

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 deleted this line:

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

and it has been fixed.

+2
source

You may need to upgrade react and react-dom . Despite react-dom actually installed, I had this question on ^15.5.4 and it left with ^16.8.6 :

 $ # update the react and react-dom modules $ yarn add react react-dom 

Make sure the two versions match exactly in package.json :

 "react": "^16.8.6", "react-dom": "^16.8.6", 

Remove yarn.lock , node_modules and yarn again.

 rm -Rf yarn.lock node_modules && yarn 
+1
source

In my case, it was an alias that I had in my webpack.conf that was looking for @hot-loader/react-dom .

+1
source

Try rm -rf node_modules && yarn or rm -rf node_modules && npm install if you use npm instead of rm -rf node_modules && npm install .

0
source

My specific problem for getting this error:

A mistake in. /src/index.js Module not found: Error: Cannot resolve 'eact-dom' to 'C: \ Users \ Jose \ Desktop \ woz-u-React \ React-Course \ response-lesson-one \ src' @ ./src/index.js 2: 0-32 @multi (webpack) -dev server / client? http: // localhost: 8080 ./src/index.js

To solve this problem, I had to unzip the folder before installation.

0
source

Do you use typewriting for your project?

I have the same error too

I fixed it by installing yarn install react-router-dom

because before that I only set @ types / to respond to the router

0
source

Source: https://habr.com/ru/post/1015431/


All Articles