awsmobile-cli icon indicating copy to clipboard operation
awsmobile-cli copied to clipboard

jest-haste-map: @providesModule naming collision: Duplicate module name

Open C2P1 opened this issue 6 years ago • 42 comments

Hello,

Trying to run npm start on my project is now giving me the following error:

Error: jest-haste-map: @providesModule naming collision: Duplicate module name: app Paths: /Users/c2p1/apps/awsmobilejs/#current-backend-info/cloud-api/Table/package.json collides with /Users/c2p1/apps/awsmobilejs/backend/cloud-api/Table/package.json

both of these package.json are identical and have the field: "name": "app"

I am now currently unable to build and run my app due to this.

Whenever I use the command awsmobile pull I enter Yes to the question

Sync corresponding contents in backend/ with #current-backend-info/

and it to me it appears like this is where the issue is created. Should I not be syncing the contents? How do I fix this so I can build my project?

Thanks!

C2P1 avatar Jul 24 '18 20:07 C2P1

The contents in the #current-backend-info folder and the backend folder are pretty much the same after each synchronization with the cloud. Then you develop your work in the backend and push the changes up to the cloud. That's the reason you see the two packages named the same.

Jest is a unit test framework, it's not part of the awsmobile-cli. I'd suggest you to exclude the #current-backend-info folder from being tested by jest-haste-map, and you should be able to build your project fine.

UnleashedMind avatar Jul 24 '18 21:07 UnleashedMind

Thanks for your reply!

I know that this used to be fine, as I've had no problems before, but since upgrading to react-native 0.56.0 this issue has started happening. Right now, I currently can't find how to exclude the #current-backend-info from the jest-haste-map. I will keep looking into it, but it seems odd that to be able to use awsmobile I then have to manually exclude some of the files it installs.

On the topic of awsmobile, is there any reason my project needs awsmobile folders prepended by a '~'? Can these be deleted?

C2P1 avatar Jul 27 '18 17:07 C2P1

awsmobile folders with name prefix '~' are backups, awsmobile-cli does not want you to loose your files, so if the cli is creating the contents in the awsmobilejs folder anew, it backs up the original contents in the backup folders. If you don't need those files, you can delete them, the cli doesn't use them.

UnleashedMind avatar Jul 27 '18 22:07 UnleashedMind

Hi, I am also running into the same problem but instead i have the package.json colliding with two different tables on my Cloud-api folder screen shot 2018-07-28 at 12 47 04 pm

This is my folder hierarchy screen shot 2018-07-28 at 12 48 57 pm

any ideas on how to fix this? Thank you

juang97 avatar Jul 28 '18 16:07 juang97

Hi @juang97, did this issue start being a problem after you had run a npm install or npm audit fix ?

C2P1 avatar Jul 29 '18 09:07 C2P1

@UnleashedMind, if I delete #current-backend-info will things still work? I have yet to find a way to exclude it from Jest-Haste-Map and this is preventing my app from running.

Next time when I do an

awsmobile pull

and say yes to sync info, will I then get a new #current-backend-info folder created? I

C2P1 avatar Jul 29 '18 19:07 C2P1

@C2P1. I was able to patch this issue by blacklisting the Table name under the awsmobile folder. This approach doesnt exactly fix the problem but everything is working as expected for me. If you are interested, take a look here https://stackoverflow.com/questions/41813211/how-to-make-react-native-packager-ignore-certain-directories

juang97 avatar Jul 30 '18 21:07 juang97

I'm having this exact same problem. I was just about to post and ask a question about it... but it's here already.

(node:90796) UnhandledPromiseRejectionWarning: Error: jest-haste-map: @providesModule naming collision: Duplicate module name: app Paths: /Users/mjc128/Desktop/ReactNativeKoalaCall/awsmobilejs/backend/cloud-api/globalSettings/package.json collides with /Users/mjc128/Desktop/ReactNativeKoalaCall/awsmobilejs/backend/cloud-api/imageSets/package.json

I've tried multiple solutions, but nothing... I can no longer compile my app. I've tried clearing the jest cache map on run, and nothing, tried removing react-native and reinstalling react-native and nothing, I also tried removing the entire node_modules folder and reinitialising, but nothing.

michaelcuneo avatar Aug 06 '18 06:08 michaelcuneo

As stated by @juang97 I followed the same procedure, and added the following to a file nammed rn-cli.config.js in the root of my project...

const blacklist = require('metro').createBlacklist;

module.exports = {
  getBlacklistRE: function() {
    return blacklist([/awsmobilejs\/.*/]);
  }
};

Works 100% fine since then.

Thanks guys.

michaelcuneo avatar Aug 07 '18 04:08 michaelcuneo

@michaelcuneo 's solution worked for me. Thanks :)

7772 avatar Aug 23 '18 18:08 7772

Hi, im having this problem too, but with react-native module. The build is succeeded, but when it start to run the app the error show the following:

whatsapp image 2018-09-25 at 12 53 59 pm

I tried to delete and reinstall node_modules, clear cache, but nothing.

Ivanrs297 avatar Sep 25 '18 17:09 Ivanrs297

Yup, I'm seeing the same thing @Ivanrs297. I'm trying to figure out how to block jest from peering into my iOS build area now...

emlynmac avatar Sep 25 '18 18:09 emlynmac

And so what I did was to rename the package.json -> package.json-off in the ios/Pods/React directory and it's good. If anyone knows how to tell jest-haste-map to ignore the iOS directory, that would be great to know. @Ivanrs297

emlynmac avatar Sep 25 '18 18:09 emlynmac

it's good? I renamed package.json -> package.json-off in ios/Pods/React com.facebook.react.JavaScript (9): EXC_BAD_ACCESS happened...

shinriyo avatar Sep 25 '18 23:09 shinriyo

react and react-native packages should be installed globally and not within any packages node_modules folder... or it’ll break it like this.

michaelcuneo avatar Sep 26 '18 00:09 michaelcuneo

My problem was AdMob plugin. I removed pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons' from my ios/Podfile and pod install in ios folder again. I resolved.

shinriyo avatar Sep 26 '18 01:09 shinriyo

@shinriyo if it doesn't work for you, maybe you have something else going on. @michaelcuneo I find that statement hard to believe - as the react-native init myApp includes react and react-native into the node_modules directory.

emlynmac avatar Sep 26 '18 03:09 emlynmac

@emlynmac thanks, it works but this is a temporary solution, we hope this can be fixed in newer versions

Ivanrs297 avatar Sep 26 '18 14:09 Ivanrs297

@emlynmac I explained what I meant really poorly. I mean, if you have a project called Potato, with node_modules inside, it can have react-native in there... but if you have a project inside node_modules called 'potato_helper, which also houses it's own node_modules folder, and dependencies, but one of these dependencies is react-native, and is a different version to that of the global node_modules folder in the main package of Potato... issues can occur, and cause the declaration definition issues... at least that's what has caused issues for me in the past.

michaelcuneo avatar Sep 27 '18 09:09 michaelcuneo

@emlynmac I explained what I meant really poorly. I mean, if you have a project called Potato, with node_modules inside, it can have react-native in there... but if you have a project inside node_modules called 'potato_helper, which also houses it's own node_modules folder, and dependencies, but one of these dependencies is react-native, and is a different version to that of the global node_modules folder in the main package of Potato... issues can occur, and cause the declaration definition issues... at least that's what has caused issues for me in the past.

@michaelcuneo Did anyone find the solution for this issue?

ovpv avatar Nov 27 '18 10:11 ovpv

I am having the same issue, not managed to a solution. where do you find the rn-cli.config.js in the project?

psalmdawg avatar Dec 01 '18 02:12 psalmdawg

hi i find the problem. two folder node_modules, example: node_modules and node_modules_test. clear the folder node_modules_test. it's work for me.

wilywork avatar Dec 05 '18 11:12 wilywork

I am having the same issue, not managed to a solution. where do you find the rn-cli.config.js in the project?

@psalmdawg you can create one look here

shuiRong avatar Dec 29 '18 15:12 shuiRong

the fix rn-cli.config.js and changing the blacklist folder name to #current-cloud-backend worked for me.


// blacklist is a function that takes an array of regexes and combines
// them with the default blacklist to return a single regex.

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

nara avatar Jan 18 '19 22:01 nara

I can confirm this works rn-cli.config.js

module.exports = {
 resolver: {
   blacklistRE: /amplify\/.*/
 }
};

elorzafe avatar Jan 19 '19 01:01 elorzafe

For future reference, this solution worked for me

https://stackoverflow.com/a/51372213/5673311

abdul-elah-js avatar Feb 03 '19 17:02 abdul-elah-js

hi i find the problem. two folder node_modules, example: node_modules and node_modules_test. clear the folder node_modules_test. it's work for me.

@wilywork's reply worked perfectly for me, I made a backup of node_modules folder as node_modules_bkp. Removed the backup folder, worked!

arhmnsh avatar Mar 05 '19 09:03 arhmnsh

@abdul-elah-js do you mind share solution, link is not working, thanks

GreenRidingHood avatar Mar 26 '19 21:03 GreenRidingHood

@nara's solution worked well for me here:

rn-cli.config.js


module.exports = {
 resolver: {
   blacklistRE: /#current-cloud-backend\/.*/
 }
};
> react-native start --config=rn-cli.config.js --resetCache

When I did blacklistRE: /amplify\/.*/ it started to throw errors on the amplify modules within the solution (ie. @aws-amplify/auth doesn't exist) which makes sense since they weren't included.

> react-native --version
react-native-cli: 2.0.1
react-native: 0.59.1

ryanjones avatar Mar 31 '19 14:03 ryanjones

Also if you are using typescript, I added the blacklist in metro.config.js instead

jimji1005 avatar Apr 10 '19 20:04 jimji1005