Skip to content

fix: improve worklets version resolution and error messages for monor…#9238

Open
elizhabiboullah wants to merge 1 commit intosoftware-mansion:mainfrom
elizhabiboullah:fix/improve-worklets-version-validation-monorepo
Open

fix: improve worklets version resolution and error messages for monor…#9238
elizhabiboullah wants to merge 1 commit intosoftware-mansion:mainfrom
elizhabiboullah:fix/improve-worklets-version-validation-monorepo

Conversation

@elizhabiboullah
Copy link
Copy Markdown

Summary

Fixes worklets version resolution in pnpm monorepo setups.

In pnpm monorepos, require('react-native-worklets/package.json') resolves from Reanimated's own install location rather than the user's project. Due to pnpm's strict dependency isolation, this can fail even when worklets is correctly installed in the project, producing a misleading "package isn't installed" error during pod install.

This PR adds a fallback resolution path using require.resolve with paths: [process.cwd()] and improves error messages with monorepo-specific guidance (e.g., using package manager overrides/resolutions).

All changes are backwards compatible, existing resolution is tried first.

Test plan

  1. Create a pnpm monorepo with two apps sharing react-native-reanimated
  2. Install react-native-worklets in each app's package.json
  3. Run cd apps/my-app && npx pod-install
  4. Before this fix: validation fails with "react-native-worklets package isn't installed"
  5. After this fix: validation correctly finds the installed worklets version and succeeds

Manual verification: the fix was validated in a real pnpm monorepo where Reanimated 4.3.0 with worklets 0.8.1 was failing to resolve during pod install

…epo setups

In pnpm monorepos, require('react-native-worklets/package.json') may fail
to resolve from Reanimated's install location due to pnpm's strict
dependency isolation. This causes false 'package not installed' errors
even when worklets is correctly installed in the project.

Changes:
- Add fallback resolution using require.resolve with paths:[process.cwd()]
  to find worklets from the project root when the standard require fails.
- Improve error messages with monorepo-specific guidance (use overrides/
  resolutions to enforce consistent versions across the workspace).
- Both changes are backwards compatible — existing behavior is preserved
  as the primary path, with monorepo fallbacks added.
@tjzel tjzel self-assigned this Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants