React Native isn't compatible with yarn pnp
See original GitHub issueEnvironment
[skip envinfo]
react-native info
doesn’t work in this scenario:
Command ``info`` unrecognized. Make sure that you have run ``npm install`` and that you are inside a react-native project.
Description
If you enable yarn pnp for a React Native app, it doesn’t work. Perhaps something is hardcoded to look in ./node_modules
?
The resulting error is: Error: Couldn't find a suitable Node resolution for unqualified path "<path-to-your-rn-project>/node_modules/react-native/local-cli/cli.js"
Reproducible Demo
- Create a new react native app via
react-native init someproject
cd someproject
- enable yarn pnp:
yarn --enable-pnp
yarn start
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
How to use Yarn 3 with React Native | by Tom McIntosh
This article will explain what PnP is, why React Native does not support it, and how we can work around this to enjoy...
Read more >Plug'n'Play | Yarn - Package Manager
An overview of Plug'n'Play, a powerful and innovative installation strategy for Node.
Read more >Yarn v2 PnP is simply a lifesaver if you have a medium+ sized ...
Yarn v2 PnP is simply a lifesaver if you have a medium+ sized monorepo. We have a monorepo with 180 packages here. Without...
Read more >It's 2021, and You Should Switch to Yarn 2 - Atomic Spin
1. Backwards Compatibility with node_modules ... Yarn 2 uses a new Plug'n'Play (PnP) architecture that is a huge departure from how npm projects ......
Read more >Newest 'yarn-v2' Questions - Stack Overflow
Yarn v3.3.0 Node v16.13.1 When I hit npx react-native run-android ... I'm not an expert in pnp, actually was setting up this for...
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 FreeTop 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
Top GitHub Comments
That path is hard coded in the project.pbxproj file of the iOS app. That’s just one spot though, the native app projects resolve the native module dependencies using file paths pointing to node_modules. They are unable to run a JS based resolver to find those dependencies in the current conventions of React Native. This looks like a tough nut to crack, considering the PNP proposal only seems to talk about node.js and modifying the require hook. Any modifications to RN that only accounts for PNP would mean that npm won’t work with React Native anymore. Maybe you can open a discussion for this in the discussions repo? I doubt this will be resolved quickly as an issue.
I am tackling this issue first over at the repo for
react-native-cli
:https://github.com/react-native-community/react-native-cli/issues/27
I think the bulk of the work for this is in the CLI half of React Native