this problem occurred after deploying sanity to my project(I don’t know if it’s the source of the problem but just wanted to share it.)
[This is what I see in the emulator]
(https://i.stack.imgur.com/otbGz.png)
and the following is what appears in the terminal:
Error: Duplicated files or mocks. Please check the console for more info
at setModule (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro-file-map/src/index.js:553:17)
at workerReply (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro-file-map/src/index.js:624:9)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 27260)
at /home/faisalmwy/development/react-native/food-delivery/node_modules/metro-file-map/src/index.js:395:22
at DependencyGraph.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/node-haste/DependencyGraph.js:94:5)
at Bundler.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/Bundler.js:75:5)
at IncrementalBundler.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/IncrementalBundler.js:327:5)
at Server.ready (/home/faisalmwy/development/react-native/food-delivery/node_modules/metro/src/Server.js:1247:5)
I’ve searched for this problem before, some said to delete the package-lock.json
and node_modules
, but it didn’t work. others said to reinstall npm altogether. that didn’t work also. I also tried running the app on a different local host than usual, since sometimes I and a friend of mine connect at the same time.
I’ve solved the problem, I typed the answer in the answers section
Thanks for helping ❤.
2
Answers
PROBLEM: the problem was having two
package-lock.json
files. since my project has the sanity file which containspackage-lock.json
as well.SOLUTION: I've solved the problem By changing from npm to yarn, I tried to convert the project from npm to yarn, but that didn't work. So I had to create a new yarn project then I transferred all the files I needed from the old project, then added the packages using yarn.
I imagine this problem wouldn't happen only with sanity, but with any case where there are two package-lock.json files.
Have you tried to stop the application and do the below process:
cd android
andgradlew clean
node_modules
andpackage-lock.json
npm i