-
-
Notifications
You must be signed in to change notification settings - Fork 118
fix: Mark react-native-nitro-modules peer dependency as optional #1516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,6 +66,36 @@ If your app fails to build after installing Nitro or a library powered by Nitro, | |
| </TabItem> | ||
| </Tabs> | ||
|
|
||
| ## Nitro was installed twice | ||
|
|
||
| If your app crashes at startup with: | ||
|
|
||
| ``` | ||
| Nitro was installed twice: once with native version X and once with JS version Y. | ||
| ``` | ||
|
|
||
| ...then two different copies of `react-native-nitro-modules` ended up in your project - the native build linked one, and Metro bundled the other. | ||
|
|
||
| The most common cause is **installing a Nitro pre-release** (e.g. `0.37.0-beta.0`). Semver ranges never match pre-release versions, so a library declaring `"react-native-nitro-modules": "*"` as a required peer dependency does not consider the beta a match - and your package manager silently installs a second, stable copy inside that library's `node_modules` to satisfy the peer. | ||
|
|
||
| To fix it: | ||
|
|
||
| 1. Check how many copies you have: | ||
| ```sh | ||
| npm ls react-native-nitro-modules | ||
| ``` | ||
| 2. If a library nests its own copy, ask the library author to mark the peer dependency as [optional](../getting-started/how-to-build-a-nitro-module#11-install-nitro-and-nitrogen). | ||
| 3. As a workaround until then, force a single version from your app's `package.json`: | ||
| ```json title="package.json" | ||
| { | ||
| "overrides": { | ||
| "react-native-nitro-modules": "0.37.0-beta.0" | ||
| } | ||
|
Comment on lines
+91
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When the app installed the beta normally, npm records a direct dependency such as Useful? React with 👍 / 👎. |
||
| } | ||
| ``` | ||
| (use `resolutions` instead of `overrides` for Yarn) | ||
| 4. Delete `node_modules` and reinstall - package managers often leave the stale nested copy on disk even after the lockfile is fixed. | ||
|
|
||
| ## Runtime error | ||
|
|
||
| If your app crashes at runtime, make sure to inspect the native logs. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The published
packages/react-native-nitro-modules/README.mdstill tells library authors to add only the required"react-native-nitro-modules": "*"peer (lines 25–37). Authors following the npm/GitHub landing-page instructions instead of this Docusaurus page will therefore continue producing packages that trigger the duplicate installation under Bun with a Nitro prerelease, recreating the exact runtime failure this change is intended to prevent.Useful? React with 👍 / 👎.