[Bug?]: React Native monorepo support and yarn 3.1+
See original GitHub issueSelf-service
- I’d be willing to implement a fix
Describe the bug
Yarn 3.1.0 now hoists dependencies of dependencies when using installConfig.hoistingLimits: "workspaces".
This is a new behaviour compared to 3.0.2
This is breaking some setups, in my case with a React Native app in a monorepo. Metro (React Native bundler) expects all of its dependency tree to be in one unique node_module folder.
From the changelog I understand the previous behaviour might have been unwanted and 3.1.0 “optimized” things, but in practice it breaks setups that relied on it.
To reproduce
As this is a behaviour change and not a bug, I am not sure you need a way to easily reproduce it?
Environment
System:
OS: macOS 12.0.1
CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Binaries:
Node: 16.13.0 - /private/var/folders/1b/wb5vmt3x7kg8gcgt4l11wbjm0000gn/T/xfs-981831cb/node
Yarn: 3.1.0 - /private/var/folders/1b/wb5vmt3x7kg8gcgt4l11wbjm0000gn/T/xfs-981831cb/yarn
npm: 8.1.0 - /usr/local/Cellar/node@16/16.13.0/bin/npm
Additional context
Should this be a feature request for a new hoistingLimits value for hoisting the whole dependency tree?
Issue Analytics
- State:
- Created 2 years ago
- Comments:33 (12 by maintainers)
Top Results From Across the Web
Unable to resolve "react-native" on Monorepo project
I'm trying to insert an Expo application inside a monorepo project, but I get an error with React Native. I used expo-yarn-workspaces and ......
Read more >Yarn 3.1 Corepack, ESM, pnpm, Optional Packages
With React Native not supporting PnP, and it appears no one is working on it, is there any benefit to upgrading to 3.x...
Read more >Monorepos in RN | React Native London | February 2022
Callum Hemsley: Running React Everywhere: Monorepos in RNPopularised by tech giants like Google, monorepos have become increasingly popular ...
Read more >Recently Active 'yarnpkg' Questions - Stack Overflow
I'm working on a project in React and ran into a problem that has me stumped. Whenever I run yarn start I get...
Read more >@bugsnag/js | Yarn - Package Manager
Bugsnag error monitoring & reporting for JavaScript. Automatically detect JavaScript errors in the browser, Node.js and React Native, with plugins for React ...
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

I have been able to test the monorepo instructions on this page: https://docs.expo.dev/guides/monorepos/
expo/metro-confignode_packagesfolder (in the root of the repo) for the various build commandsexport PROJECT_ROOT=$PWDin the “Bundle React Native code and images” build step--no-jetifierto the android build command (Jetifier should no longer be needed on modern apps)This allowed me to build my React Native app without the need for hoisting and with the latest yarn version 🎉
I recently switched to https://microsoft.github.io/rnx-kit/ and it handles a yarn 3 monorepo (with
node_moduleslinker) correctly.Mostly due to https://microsoft.github.io/rnx-kit/docs/tools/metro-resolver-symlinks