I'm using React Native with the typescript template: npx react-native init someapp --template react-native-template-typescript
Whenever I try to: import {Provider} from 'react-redux';
in index.js or App.tsx
I get the following error:
Error: Unable to resolve module ../../../../redux
from node_modules\react-redux\lib\connect\mapDispatchToProps.js
:
Note: no errors are occurred when I import redux in the project to create the redux store.
Here's my package.json:
{"name": "someapp","version": "0.0.1","private": true,"scripts": {"android": "react-native run-android","ios": "react-native run-ios","start": "react-native start","test": "jest","lint": "eslint . --ext .js,.jsx,.ts,.tsx" },"dependencies": {"@react-native-community/masked-view": "^0.1.10","@react-navigation/material-bottom-tabs": "^5.2.16","@react-navigation/native": "^5.7.3","@react-navigation/stack": "^5.9.0","@reduxjs/toolkit": "^1.4.0","@types/react-native-webrtc": "^1.75.1","@types/react-redux": "^7.1.9","@types/redux": "3.6.31","axios": "^0.20.0","react": "16.13.1","react-native": "0.63.2","react-native-config": "^1.3.3","react-native-elements": "^2.2.1","react-native-gesture-handler": "^1.7.0","react-native-linear-gradient": "^2.5.6","react-native-paper": "^4.0.1","react-native-reanimated": "^1.13.0","react-native-safe-area-context": "^3.1.6","react-native-screens": "^2.10.1","react-native-svg": "^12.1.0","react-native-vector-icons": "^7.0.0","react-native-webrtc": "^1.84.0","react-redux": "^7.2.1","redux": "^4.0.5" },"devDependencies": {"@babel/core": "^7.8.4","@babel/runtime": "^7.8.4","@react-native-community/eslint-config": "^1.1.0","@types/jest": "^25.2.3","@types/react-native": "^0.63.2","@types/react-test-renderer": "^16.9.2","@typescript-eslint/eslint-plugin": "^2.27.0","@typescript-eslint/parser": "^2.27.0","babel-jest": "^25.1.0","babel-plugin-module-resolver": "3.2.0","eslint": "^6.5.1","eslint-import-resolver-babel-module": "5.1.0","eslint-plugin-import": "2.18.2","jest": "^25.1.0","metro-react-native-babel-preset": "^0.59.0","prettier": "^2.0.4","react-native-svg-transformer": "^0.14.3","react-test-renderer": "16.13.1","redux-devtools": "^3.7.0","typescript": "^3.8.3" },"jest": {"preset": "react-native","moduleFileExtensions": ["ts","tsx","js","jsx","json","node" ] }}
Things I tried:
Removing node_modules -> delete yarn.lock -> yarn cache clean -> yarn -> cd android -> ./gradlew clean -> cd .. -> yarn android
Adding/Removing/Trying one without the other:
"@types/react-redux": "^7.1.9", "@types/redux": "3.6.31",
Made sure that
"moduleResolution": "node"
is in the compilerOptions in tsconfig.jsonTrying different versions of redux and react-redux