Module not found: Error: Can't resolve 'React' in '/home/capaj/project/node_modules/react-visibility-sensor/dist'
See original GitHub issueI have webpack 4 and react-visibility-sensor 5.0.2
and when I import like this:
import VisibilitySensor from "react-visibility-sensor"
I get
ERROR in ../node_modules/react-visibility-sensor/dist/visibility-sensor.js
Module not found: Error: Can't resolve 'React' in '/home/capaj/git_projects/looop/project-alpha/node_modules/react-visibility-sensor/dist'
@ ../node_modules/react-visibility-sensor/dist/visibility-sensor.js 4:286-324
@ ./src/pages/student-topic-detail-page/StudentTopicDetailPage.tsx
@ ./src/components/LooopRoutes.tsx
@ ./src/components/App.js
@ ./src/app/app.js
@ ./src/index/index.js
@ multi webpack-dev-server/client?http://localhost:4001 webpack/hot/dev-server ./src/index/index
ERROR in ../node_modules/react-visibility-sensor/dist/visibility-sensor.js
Module not found: Error: Can't resolve 'ReactDOM' in '/home/capaj/git_projects/looop/project-alpha/node_modules/react-visibility-sensor/dist'
@ ../node_modules/react-visibility-sensor/dist/visibility-sensor.js 4:286-324
@ ./src/pages/student-topic-detail-page/StudentTopicDetailPage.tsx
@ ./src/components/LooopRoutes.tsx
@ ./src/components/App.js
@ ./src/app/app.js
@ ./src/index/index.js
@ multi webpack-dev-server/client?http://localhost:4001 webpack/hot/dev-server ./src/index/index
when I change to import the source file:
import VisibilitySensor from 'react-visibility-sensor/visibility-sensor'
it works great.
The webpack thingy seems to think I the app run in an UMD loader and hence it tries to load deps from globals.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:15
Top Results From Across the Web
Module not found: Can't resolve 'react' - Stack Overflow
I'm trying to connect my Redux store to my React project, but I keep getting this error:.
Read more >Module not found: Can't resolve 'X' error in React | bobbyhadz
The error "Module not found: Can't resolve" occurs for multiple reasons in React: Importing a local file from an incorrect relative path. Forgetting...
Read more >module not found error | can not resolve react dom module
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >Module not found: Error: Can't resolve 'stream' in React project ...
I believe changing react-scripts to 4.0.3 and rerunning yarn install or npm install would've fixed this issue. There are several ways to get...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Actually on second thought, it is better to configure webpack to skip transpilation for
react-visibility-sensor
instead of importing what is essentially a private file. If this package changed its file structure that could cause your code to crash. So instead configurebabel-loader
as follows and leave your imports and jest config alone!import VisibilitySensor from 'react-visibility-sensor/visibility-sensor'
saving my life!