fix: Mark react-native-nitro-modules peer dependency as optional - #170
Merged
Conversation
Semver ranges never match pre-releases, so a required peer of "*" does not match e.g. 0.37.0-beta.0. Package managers then install a second, stable copy of Nitro next to the pre-release, and the native/JS version guard throws "Nitro was installed twice" at runtime. Marking the peer optional leaves the consuming app in full control of the installed Nitro version.
mrousavy
added a commit
that referenced
this pull request
Aug 20, 2026
Nitrogen 0.37.0-beta.1 renames CachedProp<T> to ReactProp<T> in generated view props, so specs were re-generated. CachedProp remains as a deprecated alias upstream and no hand-written code referenced it. Also drops the react-native-nitro-modules override again - now that #170 marks the peer dependency as optional, bun no longer installs a second stable copy alongside the pre-release, so the workaround is redundant.
mrousavy
added a commit
that referenced
this pull request
Aug 20, 2026
* feat: Upgrade Nitro to 0.37 for View improvements * fix: Force single react-native-nitro-modules resolution via overrides peerDependencies "*" doesn't match prereleases per semver, so bun auto-installed a nested 0.36.5 copy under each workspace package. Metro bundled that 0.36.5 JS while native built against 0.37.0-beta.0, tripping Nitro's "installed twice" version guard in the harness tests. * feat: Update Nitro to 0.37.0-beta.1 Nitrogen 0.37.0-beta.1 renames CachedProp<T> to ReactProp<T> in generated view props, so specs were re-generated. CachedProp remains as a deprecated alias upstream and no hand-written code referenced it. Also drops the react-native-nitro-modules override again - now that #170 marks the peer dependency as optional, bun no longer installs a second stable copy alongside the pre-release, so the workaround is redundant. * feat: Update Nitro to 0.37.0 0.37.0 stable generates identical specs to 0.37.0-beta.1, so there is no codegen delta - only the version pins and lockfiles change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Semver ranges never match pre-release versions unless a comparator shares the same
major.minor.patchtuple and carries a pre-release tag. So the"react-native-nitro-modules": "*"peer range does not match a version like0.37.0-beta.0:*>=0.0.0-0>=0.37.0-0Because the peer is required, bun satisfies it itself by installing a second, stable copy of
react-native-nitro-modulesnested inside this library. An app testing a Nitro pre-release then builds native against the pre-release while Metro bundles the stable JS, and Nitro throws at startup:Builds stay green - only runtime catches it.
Fix
Mark the peer optional, so the consuming app is the sole decider of the Nitro version. No range can express "anything, including future pre-releases" (
>=0.37.0-0just moves the breakage to 0.38.0-beta.0), so this has to be resolution behaviour rather than a cleverer range.Upstream fix in the Nitro template + docs: margelo/nitro#1516
Trade-off
optional: truealso suppresses the missing peer warning. Acceptable: a Nitro Module withoutreact-native-nitro-modulesfails loudly at build time (autolinking cannot find the pod / Gradle project), and version mismatches are caught by Nitro's runtime guard - strictly stronger than an install-time range check.The example app declares
react-native-nitro-modulesdirectly, so it is unaffected.