Skip to content
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

Error loading metro config: Cannot find module 'tslib' #4562

Closed
DaniFoldi opened this issue Feb 18, 2025 · 2 comments · Fixed by #4573
Closed

Error loading metro config: Cannot find module 'tslib' #4562

DaniFoldi opened this issue Feb 18, 2025 · 2 comments · Fixed by #4573

Comments

@DaniFoldi
Copy link

What React Native libraries do you use?

React Navigation, Expo (mobile only), Expo Application Services (EAS)

Are you using sentry.io or on-premise?

sentry.io (SaS)

@sentry/react-native SDK Version

6.6.0

How does your development environment look like?

OS: macOS 15.3
Node: 22.11.0
Expo: 52.0.35
react: 18.3.1
react-native: 0.77.0

although I think what is more relevant: we use pnpm for package manager, and it's set up as a workspace.
The app lives in /packages/app.

Sentry.init()

Sentry.init({
  dsn: constants.expoConfig?.extra?.sentry?.dsn,
  attachStacktrace: true,
  enableTracing: true,
  tracesSampleRate: 1,
  sampleRate: 1,
  debug: __DEV__,
  integrations: [
    Sentry.httpClientIntegration(),
    Sentry.reactNativeInfoIntegration()
  ]
})

Steps to Reproduce

  1. create a pnpm workspace, with an expo app in say /packages/app - make sure hoisting is disabled
  2. add sentry
  3. observe that while building, the error below is thrown.

The reason (I suspect) is that tslib is not declared as a dependency, but somehow ends up in the built file dist/js/tools/metroconfig.js (and others, but this is the first one to be found by the build process).

Expected Result

tslib is depended upon, and therefore found while importing it

Actual Result

ERROR: Error loading .../packages/app/metro.config.cjs
Reason: Cannot find module 'tslib'
Require stack:
- .../node_modules/.pnpm/@[email protected][email protected]_@[email protected]_@[email protected]_@babel+co_r4te4muu5h7i3sl6odqu22xk5u/node_modules/@sentry/react-native/dist/js/tools/metroconfig.js
@krystofwoldrich
Copy link
Member

Hi @DaniFoldi,
thank you for the message, you are right the SDK doesn't depend on tslib and so shouldn't import it.

We will remove the tslib import -> #4573

@krystofwoldrich krystofwoldrich self-assigned this Feb 20, 2025
@krystofwoldrich krystofwoldrich moved this from Needs Discussion to Needs Review in Mobile & Cross Platform SDK Feb 20, 2025
@DaniFoldi
Copy link
Author

Hi @krystofwoldrich,

Awesome, thanks for the quick resolution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants