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

[Expo] Failed to construct transformer: Error: Cannot find module 'metro-react-native-babel-transformer' #410

Open
alexander-at-t opened this issue Jan 31, 2025 · 0 comments

Comments

@alexander-at-t
Copy link

alexander-at-t commented Jan 31, 2025

The following code leads to an error in metro bundler in Expo project:

const reactNativeTransformer = (() => {
try {
return require("@react-native/metro-babel-transformer");
} catch (error) {
return require("metro-react-native-babel-transformer");
}
})();

In case of expo project, both dependencies could be absent: @react-native/metro-babel-transformer and metro-react-native-babel-transformer.

A fix would be to make reactNativeTransformer and expoTransformer functions, instead of self-executed functions.

Then when we require 'react-native-svg-transformer/expo', then it will not try to execute code of reactNativeTransformer, and so will not throw exception.

@alexander-at-t alexander-at-t changed the title Failed to construct transformer: Error: Cannot find module 'metro-react-native-babel-transformer' [Expo] Failed to construct transformer: Error: Cannot find module 'metro-react-native-babel-transformer' Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant