You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support for resolving Yarn Plug 'n Play modules #308
Do you want to request a feature or report a bug?
Request a feature
What is the current behavior?
Metro does not (yet) have PnP support
If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.
What is the expected behavior?
I think it would be very handy if Metro had support for resolving Yarn PnP modules.
Not only would there be the benefits you'd get for using it in other project, I believe that if this Yarn feature request is able to be resolved, this could be a reasonable alternative to using symlinks (since they are not able to be supported for technical reasons)
Curious how this is going. If the internal resolver is inappropriate for open source, perhaps I could make an attempt at implementing one.
I think this could probably be a first-class metro feature. Only thing I can't really figure out is a good way to unit test it. Non-PnP mode has really nice virtual filesystem for testing, and this wouldn't be able to make use of that without heavy modification (probably)
Yep, I think FB removed it about a year ago since they don't use it internally. You should be able to add it back by overriding resolveRequest in your configuration, though.
But yes, it would be good to get it back as a option as well :)
Reacted by zorudikku, Alexander Lyon, Victor Malov, Tiago, Jules Sam. Randolph, Dirk Geurs, Léo Pradel, Tasos Maroudas, alamothe, Dawson Booth and 2 more
Would it help if I provide a pull request to get this back in? If there is no interest in adding this back in we could create a separate package for it so that at least React Native has a way forward for adopting Yarn 2.
Reacted by Younes, Dean Rorris, Tasos Maroudas, Christophe Hurpeau, Enrico Valbuena and alamothe
Would it help if I provide a pull request to get this back in? If there is no interest in adding this back in we could create a separate package for it so that at least React Native has a way forward for adopting Yarn 2.
I'd love to see this either way, but would use a separate package if metro isn't interested in adding it.
edit: actually, no. I guess yarn had implicitly decided to use node_modules event though it wasn't configured to do so. PnP does not work, but you can use a yarn mono repo with hoisting to a root node_modules via a few autogenerated symlinks with that expo-yarn-workspaces package
Metro now (since 0.79.0's default-on symlink support) fully supports modern package managers, including Yarn 2+ with nodeLinker: pnpm and nodeLinker: node-modules. I believe that's most of the ask from folks in this thread. In particular, Metro fully supports workspaces now.
The specific PnP feature (nodeLinker: pnp) is not supported (it was briefly, between 60bad94, v0.50.0, and 1ff21a8, v0.55.0). It doesn't produce Node.js-compatible node_modules layouts and has its own algorithm that always needs bespoke support. Some other bundlers support it, some (eg TurboPack) don't.
Supporting it correctly according to Metro's architecture isn't trivial, and isn't a priority.
Closing as not planned. If folks still want PnP specifically even now that we support symlinks, workspaces etc, please open a new issue. If there's still sufficient interest we might reconsider.
Activity
arcanis commentedon Nov 6, 2018
It actually already does! We just need to open-source the resolver in a separate package (or make it native, possible) 😃 ping @rafeca
empyrical commentedon Nov 15, 2018
Curious how this is going. If the internal resolver is inappropriate for open source, perhaps I could make an attempt at implementing one.
I think this could probably be a first-class metro feature. Only thing I can't really figure out is a good way to unit test it. Non-PnP mode has really nice virtual filesystem for testing, and this wouldn't be able to make use of that without heavy modification (probably)
vjpr commentedon Dec 4, 2018
I found it implemented here: 60bad94
dalinarkholin commentedon May 5, 2020
@arcanis @empyrical was Pnp support removed? Im guessing that is why this is still open?
arcanis commentedon May 5, 2020
Yep, I think FB removed it about a year ago since they don't use it internally. You should be able to add it back by overriding
resolveRequestin your configuration, though.arlyon commentedon May 8, 2020
Now that yarn uses pnp by default, can we consider adding it again?
dalinarkholin commentedon May 8, 2020
@arlyon I just added an example repo with pnp and react native working. Checkout the metro.config.js here: https://github.com/dalinarkholin/react-native-pnp-enabled
Also my comment here: react-native-community/cli#27 (comment)
But yes, it would be good to get it back as a option as well :)
Dirklectisch commentedon Sep 10, 2020
Would it help if I provide a pull request to get this back in? If there is no interest in adding this back in we could create a separate package for it so that at least React Native has a way forward for adopting Yarn 2.
dvicory commentedon Sep 10, 2020
I'd love to see this either way, but would use a separate package if metro isn't interested in adding it.
evelant commentedon Jan 24, 2022
Since it's 3 years and counting with no movement on this I'm guessing it's never going to happen. The expo crew seems to worked around it. See here: https://github.com/expo/expo/tree/master/packages/expo-yarn-workspaces
I was able to use expo-yarn-workspaces to get my vanilla RN app to work in a yarn workspace
alamothe commentedon Jan 25, 2022
@evelant Yarn PNP or no?
evelant commentedon Jan 25, 2022
edit: actually, no. I guess yarn had implicitly decided to use node_modules event though it wasn't configured to do so. PnP does not work, but you can use a yarn mono repo with hoisting to a root node_modules via a few autogenerated symlinks with that expo-yarn-workspaces package
Nantris commentedon Mar 23, 2023
Any update? Yarn 2 has been stable and widely used for years. It would be nice if the React Native ecosystem could get on-board.
robhogan commentedon Sep 11, 2026
Metro now (since 0.79.0's default-on symlink support) fully supports modern package managers, including Yarn 2+ with
nodeLinker: pnpmandnodeLinker: node-modules. I believe that's most of the ask from folks in this thread. In particular, Metro fully supports workspaces now.The specific PnP feature (
nodeLinker: pnp) is not supported (it was briefly, between 60bad94, v0.50.0, and 1ff21a8, v0.55.0). It doesn't produce Node.js-compatible node_modules layouts and has its own algorithm that always needs bespoke support. Some other bundlers support it, some (eg TurboPack) don't.Supporting it correctly according to Metro's architecture isn't trivial, and isn't a priority.
Closing as not planned. If folks still want PnP specifically even now that we support symlinks, workspaces etc, please open a new issue. If there's still sufficient interest we might reconsider.
Nantris commentedon Sep 12, 2026
Thank you for the update @robhogan.
I created #1928 for people still interested in PnP support (as I certainly am).