Error: Duplicated files or mocks.

Hey all, so I think this is a problem with AWS Amplify as opposed to Expo, but I’m hoping someone here can help me out. This is the exact same error as this poor fellows, who didn’t get any response: Error: Duplicated files or mocks. Please check the console for more info

Error: Duplicated files or mocks. Please check the console for more info
    at setModule (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:691:9)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 14037)

Here are the console logs:

jest-haste-map: Haste module naming collision: projectamplifyjsc7fc9745PostConfirmation
  The following files share their name; please adjust your hasteImpl:
    * <rootDir>\amplify\#current-cloud-backend\function\projectamplifyjsc7fc9745PostConfirmation\src\package.json
    * <rootDir>\amplify\backend\function\projectamplifyjsc7fc9745PostConfirmation\src\package.json    

Failed to construct transformer:  DuplicateError: Duplicated files or mocks. Please check the console for more info
    at setModule (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 50) {
  mockPath1: 'amplify\\#current-cloud-backend\\function\\projectamplifyjsc7fc9745PostConfirmation\\src\\package.json',
  mockPath2: 'amplify\\backend\\function\\projectamplifyjsc7fc9745PostConfirmation\\src\\package.json'}
Error: Duplicated files or mocks. Please check the console for more info
    at setModule (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 50)
Error: Duplicated files or mocks. Please check the console for more info
    at setModule (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:620:17)
    at workerReply (C:\Users\me\Desktop\project\node_modules\jest-haste-map\build\index.js:691:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Promise.all (index 50)

Please help

Creating rn-cli.config.js with the contents below fixed this issue for me.

// works with older react native versions
// const blacklist = require('metro').createBlacklist;

const blacklist = require('metro-config/src/defaults/blacklist');

module.exports = {
  resolver: {
    blacklistRE: blacklist([/#current-cloud-backend\/.*/]),
  },
};

i’d recommend following this guide for customizing metro with expo: Customizing Metro - Expo Documentation

the config you provided will clobber any other resolver configuration. so you can either spread the default expo/metro-config or use config.resolver.blacklistRE (note: this changes in sdk 43 to blocklist iirc)

Thanks for the info i will try to figure it out for more.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.