The full error I get is "error: Error: Unable to resolve module react-native from /.../.../index.js: react-native could not be found within the project or in these directories: node_modules"
I am using pnpm version 7.17.0, react native version 0.70.6, and node version v19.1.0, on M1 macos 13.0.1.
It seems like pnpm isn't supported by React Native, but it took me a very long time to figure out that this is because of some incompatibility with pnpm.
Knowing this incompatibility issue, I think the exact error anyone gets will mostly just include whichever dependency happens to get put first in their index.js file.
While it appears that some workarounds exist, such as here https://github.com/pnpm/pnpm/issues/3015 it is still my impression that it is a bad idea to use them together.
Am I missing any other details or context here? I am posting this question to increase visibility of the problem for anyone else.
Since react-native v0.72 you can enable experimental symlink support in metro.config.js
: https://reactnative.dev/blog/2023/06/21/0.72-metro-package-exports-symlinks#enabling-beta-features
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config')
const config = {
resolver: {
unstable_enableSymlinks: true,
},
}
module.exports = mergeConfig(getDefaultConfig(__dirname), config)