Summary
The react-native peer dependency in published react-native-macos packages uses an exact version (e.g., "react-native": "0.79.6") instead of a caret range (e.g., "react-native": "^0.79.0"). This causes installation failures with newer patch versions.
Problem
When following the Getting Started guide, users get:
npx @react-native-community/cli init myProject --version 0.79
cd myProject
npx react-native-macos-init
# Error: Command failed: npm install --save --silent "react-native-macos@^0.79.0-0"
Why This Happens
npx @react-native-community/cli init --version 0.79 installs the latest 0.79.x version (currently 0.79.7)
react-native-macos@0.79.1 declares "peerDependencies": { "react-native": "0.79.6" } (exact version)
- npm 7+ enforces strict peer dependency checking and refuses to install
Suggested Solution
Use a caret range for the react-native peer dependency when creating releases:
{
"peerDependencies": {
"react-native": "^0.79.0"
}
}
Benefits
- Accepts all patch versions (0.79.0, 0.79.1, ..., 0.79.7, etc.)
- Follows semver convention (patch versions are backward-compatible)
- Avoids installation failures when users have newer patches
- No need for
--legacy-peer-deps workaround
Current Workaround
PR #2785 adds --legacy-peer-deps to the CLI as an immediate fix.
Related
Summary
The react-native peer dependency in published react-native-macos packages uses an exact version (e.g.,
"react-native": "0.79.6") instead of a caret range (e.g.,"react-native": "^0.79.0"). This causes installation failures with newer patch versions.Problem
When following the Getting Started guide, users get:
Why This Happens
npx @react-native-community/cli init --version 0.79installs the latest 0.79.x version (currently 0.79.7)react-native-macos@0.79.1declares"peerDependencies": { "react-native": "0.79.6" }(exact version)Suggested Solution
Use a caret range for the react-native peer dependency when creating releases:
{ "peerDependencies": { "react-native": "^0.79.0" } }Benefits
--legacy-peer-depsworkaroundCurrent Workaround
PR #2785 adds
--legacy-peer-depsto the CLI as an immediate fix.Related
yarn.config.cjsenforces that a peer dependency exists on release branches