Faria Ejaz
Faria Ejaz

Reputation: 48

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'

Upvotes: 1

Views: 4515

Answers (2)

user1205028
user1205028

Reputation: 51

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

Upvotes: 1

Nick
Nick

Reputation: 461

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'
} 

Upvotes: 4

Related Questions