question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React Native isn't compatible with yarn pnp

See original GitHub issue

Environment

[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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9

github_iconTop GitHub Comments

2reactions
bartolkaruzacommented, Nov 6, 2018

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.

1reaction
empyricalcommented, Nov 14, 2018

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found