[React-Native] [Expo] Cannot find module 'react-dom' from 'styled-components.cjs.js'
See original GitHub issueEnvironment
System:
- OS: macOS 10.14
- CPU: (4) x64 Intel® Core™ i7-5557U CPU @ 3.10GHz
- Memory: 330.20 MB / 16.00 GB
- Shell: 3.2.57 - /bin/bash
Binaries:
- Node: 10.7.0 - ~/.nvm/versions/node/v10.7.0/bin/node
- Yarn: 1.7.0 - /usr/local/bin/yarn
- npm: 6.5.0 - ~/.nvm/versions/node/v10.7.0/bin/npm
npmPackages:
- styled-components: ^4.1.3 => 4.1.3
Reproduction
I’m working on a project on React native with Expo. I have a component that use a View and name Container.
import React from 'react'
import {
CameraRoll,
Button,
Dimensions,
FlatList,
TouchableHighlight,
} from 'react-native'
import styled from 'styled-components/native'
export const Container = styled.SafeAreaView`
flex: 1;
background-color: transparent;
`
I have a file to run test with react-test-renderer
who look like this :
// __tests__/Library-test.js
import React from 'react';
import {Container} from '../Library';
import renderer from 'react-test-renderer';
import 'jest-styled-components';
test('renders correctly', () => {
const tree = renderer.create(<Container />).toJSON();
expect(tree).toMatchSnapshot();
});
Expected Behavior
I was expecting to have the test working perfectly.
Actual Behavior
FAIL components/__tests__/Library-test.js
● Test suite failed to run
Cannot find module 'react-dom' from 'styled-components.cjs.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
at Object.<anonymous> (node_modules/styled-components/dist/styled-components.cjs.js:16:32)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:5
Top Results From Across the Web
Cannot find module 'react-dom/client' from 'node_modules ...
I think it's because your @testing-library/react using the newer version, just test with version of 12.1.2.
Read more >styled-components - npm
Start using styled-components in your project by running `npm i ... See the documentation about React Native for more information.
Read more >Module not found: Can't resolve 'react-dom' error | bobbyhadz
To solve the error Module not found: Error: Can't resolve 'react-dom', make sure to install the `react-dom` package by opening your terminal in...
Read more >Invalid Hook Call Warning - React
You might be using a version of react-dom (< 16.8.0) or react-native (< 0.59) that doesn't yet support Hooks. You can run npm...
Read more >failed to construct transformer react native - You.com
Failed to construct transformer: Error: Cannot find module 'vue-native-scripts' ... _load (internal/modules/cjs/loader.js:746:27) at Module.require ...
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
Hey, have you found a solution?
Yep, add
styled-components/native
in your import, notstyled-components