False positive "Multiple versions of Reanimated" because of local .yarn cache in 2.10.0
See original GitHub issueDescription
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
Issue Analytics
- State:
- Created a year ago
- Comments:17 (6 by maintainers)
Top Results From Across the Web
Troubleshooting common problems | React Native Reanimated
Multiple versions of Reanimated were detected ... This error usually happens when in your project there exists more than one instance of Reanimated....
Read more >Configuration options | Yarn - Package Manager
The cache is deemed to be relatively safe to be shared by multiple projects, even when multiple Yarn instances run at the same...
Read more >react-native-reanimated: Versions - Openbase
Full version history for react-native-reanimated including change logs. ... false positive "Multiple versions of Reanimated" because of local .yarn cache by ...
Read more >React Native Reanimated Versions - Open Source Agenda
View the latest React Native Reanimated versions. ... 2 weeks ago ... Fix false positive "Multiple versions of Reanimated" because of local .yarn...
Read more >Requiring module "node_modules\react-native-reanimated ...
js", which threw an exception: Error: Reanimated 2 failed to create a worklet, maybe you forgot to add Reanimated's babel plugin? In babel....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
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).