-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Updating Metro in a React Native project #940
Comments
Closed
I was just curious which release that would be. Is there something we can follow? |
React Native will have Metro with symlink support (minimum behind a flag) from 0.72. The first RC should be out this month, and you can follow that in Road to 0.72 if you like. |
EvanBacon
pushed a commit
to expo/expo
that referenced
this issue
Apr 13, 2023
# Why Preemptively upgrades the `expo-template-tabs` example to `metro@0.76`. Expo Router has experimental features that require `metro@0.76` that we would like users to start testing. However the documentation around upgrading Metro within a project is lacking (facebook/metro#940). We are upgrading just this template for better user adoption. These resolutions will be removed when Expo SDK supports `react-native@0.72`
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Opening this to track an issue raised in #1 (comment) - currently, there's no good way to update Metro independently of React Native. When people try to do this it's unlikely to work as expected, but there's no clear indication as to why.
(This mainly relates to "vanilla" React Native installs that use
@react-native-community/cli
, but there might be some overlap with Expo setups)Adding a
metro
dependency to yourpackage.json
This won't work because your packager (eg Yarn) will respect that your project and
react-native
specify dependencies on different versions of Metro, and install both. Your project's dependency will be installed atnode_modules/metro
, butreact-native
and@react-native-community/cli-plugin-metro
will retain their own copies of Metro deeper withinnode_modules
. When you runstart
, the latter will be used - not the version you installed.On top of this, having multiple versions of Metro installed can cause bugs, such as in #857 (comment)
Workaround
We don't recommend using a version of Metro other than the one specified by React Native and its dependencies. But, if you want to try anyway, the only correct way to force a different version of an indirect dependency is to override it at the packager level. With Yarn classic, you can use
resolutions
, NPM (and PNPM) haveoverrides
. You should override every Metro package, i.e. all of these. If folks get this working and would like to share their config here, please do!Future plans
There's some work ongoing between the maintainers of Metro, React Native and the CLI to rearrange this dependency relationship so that users can set their Metro version and receive updates. We'll close this issue when that's complete.
The text was updated successfully, but these errors were encountered: