react-native: Error: Unable to resolve module `./utils/batch`
🐛 Bug Report
after erasing node_modules folder i cannot compile anymore
error: bundling failed: Error: Unable to resolve module `./utils/batch`
from `...node_modules\react-redux\lib\index.js`:
The module `./utils/batch` could not be found from `...node_modules\react-redux\lib\index.js`.
Environment
“react”: “^16.8.6”, “react-native”: “^0.59.5”, “react-redux” : “6.0.1”
i tryed to
npm install
npm start --clear-cache
npm cache clean --force
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 16 (4 by maintainers)
@alainib I have found the solution. Problem: This happens when you install react-redux ^7.0.0 and then downgrade to ^6.0.0. People do this as expo doesn’t have dependencies for hook features in ^7.0.0 Now that you have downgraded, it won’t find ‘./utils/batch’. This batch file is only found in ^7.0.0 which means expo is caching libraries with the directory names you are in. Even if you delete the entire project directory and recreate it spelled the same, the cache still brings this error up.
Solution: instead of
expo start
ornpm start
useexpo r -c
this removes the cache associated with the build in that directory.it finally worked thank you
delete node_modules folder
package.json :
"react": "16.8.3", "react-native": "0.59.2", "react-redux": "6.0.1"
npm install
live the
node_modules\react-native\scripts\launchPackager.bat
as it withnode "%~dp0..\cli.js" start
change
@react-native-community\cli\build\commands\runAndroid\runAndroid.js
:const procConfig = { cwd: process.cwd() }
npm cache clean --force
npm start --clear-cache
react-native start --reset-cache
AND THIS STEP I DIDNT DONE BEFOREdelete
C:\Users\YOURUSERNAME\AppData\Local\Temp\metro-cache
I’m pretty sure this wouldn’t happen (didn’t happen to me at least) if you used Yarn instead of npm, it’s just way more reliable 😃. Anyway, glad you sorted it out! I feel we’re good to close it now then.
@thymikee I can confirm using yarn instead solved the issue for me