I'm trying to use @redux/toolkit
in my react-native app. However, when I run the iOS simulator I get the following error.
Metro has encountered an error: While trying to resolve module immer
from file /path-node-modules/node_modules/@reduxjs/toolkit/dist/redux-toolkit.cjs.production.min.js
, the package /path-node-modules//node_modules/immer/package.json
was successfully found. However, this package itself specifies a main
module field that could not be resolved (/path-node-modules/node_modules/immer/dist/immer.esm.mjs
. Indeed, none of these files exist:
/path-node-modules/node_modules/immer/dist/immer.esm.mjs(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
/path-node-modules/node_modules/immer/dist/immer.esm.mjs/index(.native|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json)
I found a similar issue on immer's github repo that was resolved in 2019, but I'm still seeing this today (which is weird because I have all the latest packages).
I edited the node-modules path, because it starts from my root directory.
Any ideas on how to resolve this?