Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Duplicated files or mocks. Please check the console for more info (React Native Amplify)

I am using React Native Expo and AWS Amplify as the backend for my mobile application. Also, I am using lambda trigger functions along with my AWS Amplify backend.

After adding the lambda function, I cannot run my mobile application using npm start. Here is the error I got.

enter code hereError: Duplicated files or mocks. Please check the console for more info
    at setModule (G:\GitProjFiles\React Native\ChatApp\ChatApp\node_modules\metro\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (G:\GitProjFiles\React Native\ChatApp\ChatApp\node_modules\metro\node_modules\jest-haste-map\build\index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 57)

I think the npm is detecting another node_modules folder that is related to my lambda function. Here is the file structure,

+-- .expo
+-- <b>node_modules</b>
|
+-- amplify
|   +-- backend
|      +-- function
|        +--function_name
|           +--src
|              <b>+--node_modules</b>
|              +--package.json
|              +--custom.js 
+-- src
|
+-- package.json
+-- yarn.lock

I did try deleting node_modules and re-installing, but the issue persists.

like image 852
Sahan Amarsha Avatar asked Dec 20 '25 20:12

Sahan Amarsha


1 Answers

I had a similar issue, I was using expo for my react-native mobile app. My error message was:

Failed to construct transformer:  DuplicateError: Duplicated files or mocks. 
Please check the console for more info
at setModule (/home/arsen/Desktop/SignalClone/node_modules/jest-haste- 
map/build/index.js:543:17)
at workerReply (/home/arsen/Desktop/SignalClone/node_modules/jest-haste- 
map/build/index.js:614:9)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 29625)
at /home/arsen/Desktop/SignalClone/node_modules/jest-haste- 
map/build/index.js:426:22 {
mockPath1: 
'amplify/backend/function/SignalClonePostConfirmation/src/package.json',
mockPath2: 'amplify/#current-cloud- 
backend/function/SignalClonePostConfirmation/src/package.json'}

As you see in the error msg, there are two mockPaths (mockPath1 and mockPath2). So I simply deleted one of them(mockPath2) and the issue was solved.

like image 60
Bob Dilan Avatar answered Dec 23 '25 23:12

Bob Dilan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!