0

Upon trying to hookup redux toolkit in my react native expo application, I am getting the following error solely on IOS simulators Unable to resolve "../../../../redux" from "node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.production.min.js". My code looks as follows

App.tsx

import { Provider } from "react-redux";
import { store } from "state/store";

export default function App() {
  return (
    <View style={styles.container}>
      <Provider store={store}>
        <NavigationWrapper />
      </Provider>
    </View>
  );
}

store.ts

import { configureStore } from "@reduxjs/toolkit";
import globalViewsReducer from "./slices/globalViews";

export type State = ReturnType<typeof store.getState>;

export const store = configureStore({
  reducer: {
    globalViews: globalViewsReducer,
  },
});

I know this is a redux only issue due to the warning and the fact that if I remove the redux imports from App.tsx the build completes

export default function App() {
  return (
    <View style={styles.container}>
      <NavigationWrapper />
    </View>
  );
}

My package.json is as follows

{
  "name": "app",
  "version": "1.0.0",
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web"
  },
  "dependencies": {
    "@react-navigation/bottom-tabs": "^6.5.8",
    "@react-navigation/native": "^6.1.7",
    "@react-navigation/stack": "^6.3.17",
    "@reduxjs/toolkit": "^1.9.5",
    "expo": "~48.0.18",
    "expo-status-bar": "~1.4.4",
    "prettier": "^2.8.8",
    "react": "18.2.0",
    "react-native": "0.71.8",
    "react-native-safe-area-context": "4.5.0",
    "react-native-screens": "~3.20.0",
    "react-redux": "^8.1.1"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@types/react": "~18.0.14",
    "babel-plugin-module-resolver": "^5.0.0",
    "typescript": "^4.9.4"
  },
  "private": true
}

The following screenshots are what I see, IOS has errors while android runs fine. Sometimes I even get a weird C++ error thrown in enter image description here enter image description here

Any suggestions? I have tried reinstalling the node modules and using a new emulator. All of them result in this error.

Malice
  • 181
  • 2
  • 13
  • Fix was to clear the cache, what a waste of hours of debugging https://stackoverflow.com/a/75029405/16179502 – Malice Jul 02 '23 at 17:06

0 Answers0