简体   繁体   中英

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

I have tried yarn add react react-dom but still facing these issues.If anyone can help me with this

index.js:1437 D:/ecodocs-admin/node_modules/rc-align/es/Align.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-align\es'
console.<computed> @ index.js:1437
index.js:1437 D:/ecodocs-admin/node_modules/rc-animate/es/AnimateChild.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-animate\es'
console.<computed> @ index.js:1437
index.js:1437 D:/ecodocs-admin/node_modules/rc-time-picker/es/Select.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-time-picker\es'
console.<computed> @ index.js:1437
index.js:1437 D:/ecodocs-admin/node_modules/rc-trigger/es/index.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-trigger\es'
console.<computed> @ index.js:1437
index.js:1437 D:/ecodocs-admin/node_modules/rc-trigger/es/Popup.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-trigger\es'
console.<computed> @ index.js:1437
index.js:1437 D:/ecodocs-admin/node_modules/rc-util/es/Portal.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-util\es'
console.<computed> @ index.js:1437
index.js:1437 D:/ecodocs-admin/node_modules/rc-util/es/ContainerRender.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-util\es'
console.<computed> @ index.js:1437
index.js:1437 D:/ecodocs-admin/node_modules/rc-util/es/Dom/addEventListener.js
Module not found: Can't resolve 'react-dom' in 'D:\ecodocs-admin\node_modules\rc-util\es\Dom'

Use this to install react and react-dom:

yarn add react react-dom

If this not work, you You have to fix the 'externals' configuration in webpack.config:

externals: {
   'react': 'react',
   'react-dom': 'react-dom'
} 

I think in many cases people will already have react-dom. If so, based on the comments, I think it is worth checking if you have added @hot-loader/react-dom as an alias, but forgot to install it. In such cases you need to do:

npm install -D @hot-loader/react-dom

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM