forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 157
Open
Labels
Description
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.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)- 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-depsworkaround
Current Workaround
PR #2785 adds --legacy-peer-deps to the CLI as an immediate fix.
Related
- PR fix(macos-init): add --legacy-peer-deps to npm install command #2785 - fix(macos-init): add --legacy-peer-deps to npm install command
- The peer dependency is added during the release process (not in main branch)
yarn.config.cjsenforces that a peer dependency exists on release branches