react-native-reanimated: False positive "Multiple versions of Reanimated" because of local .yarn cache in 2.10.0
Description
Hi, I’m getting an error Multiple versions of Reanimated were detected
on my gitlab runner environment. I’m using local .yarn
cache in the root of the project.
iOS:
[!] Invalid `Podfile` file:
[!] Invalid `RNReanimated.podspec` file: [Reanimated] Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected
Conflict between:
- /.yarn/v6/npm-react-native-reanimated-2.10.0-ed53be66bbb553b5b5e93e93ef4217c87b8c73db-integrity/node_modules/react-native-reanimated
- /node_modules/react-native-reanimated
.
Android:
* What went wrong:
A problem occurred evaluating project ':react-native-reanimated'.
>
Multiple versions of Reanimated were detected. Only one instance of react-native-reanimated can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/troubleshooting#multiple-versions-of-reanimated-were-detected
Conflict between:
- /.yarn/v6/npm-react-native-reanimated-2.10.0-ed53be66bbb553b5b5e93e93ef4217c87b8c73db-integrity/node_modules/react-native-reanimated
- /node_modules/react-native-reanimated
My project, however, resolves to 2.10.0
only:
yarn why v1.22.19
[1/4] 🤔 Why do we have the module "react-native-reanimated"...?
[2/4] 🚚 Initialising dependency graph...
[3/4] 🔍 Finding dependency...
[4/4] 🚡 Calculating file sizes...
=> Found "react-native-reanimated@2.10.0"
info Has been hoisted to "react-native-reanimated"
info This module exists because it's specified in "dependencies".
info Disk size without dependencies: "27.16MB"
info Disk size with unique dependencies: "27.36MB"
info Disk size with transitive dependencies: "32.86MB"
info Number of shared dependencies: 40
✨ Done in 0.32s.
Shouldn’t the yarn/npm cache be excluded from the duplicities check? Or maybe it should search only in the scope of the root node_modules
?
Steps to reproduce
iOS
- have a project with one installation of rn-reanimated of
2.10.0
- rm -rf node_modules
- yarn install --cache-folder .yarn
- cd ios
- pod install
- error ❌
Android
- have a project with one installation of rn-reanimated of
2.10.0
- rm -rf node_modules
- yarn install --cache-folder .yarn
- react-native run-android
- error ❌
Snack or a link to a repository
🤷♂️
Reanimated version
2.10.0
React Native version
0.69.4
Platforms
Android, iOS
JavaScript runtime
Hermes
Workflow
React Native (without Expo)
Architecture
Paper (Old Architecture)
Build type
No response
Device
No response
Device model
No response
Acknowledgements
Yes
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (6 by maintainers)
Commits related to this issue
- Fix false positive "Multiple versions of Reanimated" because of local `.yarn` cache (#3510) ## Description Fixes #3509. <!-- Description and motivation for this PR. Inlude Fixes #<number> i... — committed to software-mansion/react-native-reanimated by tomekzaw 2 years ago
- Fix false positive "Multiple versions of Reanimated" because of local `.yarn` cache (#3510) ## Description Fixes #3509. <!-- Description and motivation for this PR. Inlude Fixes #<number> i... — committed to software-mansion/react-native-reanimated by tomekzaw 2 years ago
- Fix false positive "Multiple versions of Reanimated" because of local `.yarn` cache (#3510) ## Description Fixes #3509. <!-- Description and motivation for this PR. Inlude Fixes #<number> i... — committed to wordpress-mobile/react-native-reanimated by tomekzaw 2 years ago
Nope. The issue only started for us with
2.12.0
- although other dependencies also changed. Something aboutreact-native-reanimated
causesyarn
to install it into two places with a monorepo, in very particular circumstances.Specifically, when
@babel/core
is listed as adevDependencies
in our subpackage, then the[root]/node_modules
and the[root]/packages/[package-name]/node_modules
both will containreact-native-reanimated
- even if we specify it innohoist
.Any ideas? We’re experiencing this due to a bug in Yarn, I guess, but I can’t find any way around it with Expo because
eas prebuild
forcibly add the problematicdevDependency
and subsequentlyreact-native-reanimated
will be installed in two places.Edit:
I found a solution! Note that this specifically is for Expo users with a monorepo. If that doesn’t describe you, this isn’t the solution you’re looking for.
Solution: Manually add
@babel/core
todevDependencies
with a version matching your monorepo’s version - thenexpo prebuild
will not disturb it.Works!
I noticed the PR is based on 3.0.0-rc.2. So I verified 3.0.0-rc.2 also gave the error. It does.
Specifying your PR:
makes pod install behave again.
@Slapbox Have you manually added
@babel/core
todevDependencies
or[root]/packages.json
or[root]/packages/[package-name]/packages.json
?Sure, go ahead, but note that the PR is based on 3.0.0-rc.2.
If you use Reanimated 2.x, I recommend using patch-package (at least until we backport this PR to the 2.x branch).
Hey @honzajerabek, thanks for reporting this issue! We will investigate it.
Thanks! In my case I was needing
react-native-reanimated
to not be hoisted, as I have a patch applied. What worked for me was listing the other libraries that were depending onreact-native-reanimated
in thenohoist
section.No, no, I’ve double-checked it a few times.
I have this error reproduced on 2.12.0. I was able to fix it by installing the version
yarn add react-native-reanimated@3.0.0-rc.2
Try doing this. I fixed the issue from these steps.
https://docs.swmansion.com/react-native-reanimated/docs/next/fundamentals/troubleshooting/#:~:text=Multiple versions of Reanimated were detected&text=It can occur when some,install the same Native Module.
Cheers
@tomekzaw works also for me! 🙌 thanks