Repository navigation
Metro babel transformer doesn't recognize .cjs config files (babel.config.cjs, .babelrc.cjs) #58525
Description
Activity
- addedNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.
on Sep 14, 2026 Warning
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
- For majority of bugs: send us a Pull Request with the RNTesterPlayground.js edited to reproduce your bug.
- If your bug is UI related: a Snack
- If your bug is build/upgrade related: a project using our Reproducer Template
You can read more about about it on our website: How to report a bug.Transferred to
react/react-native, since the Babel config loading logic lives here, not in Metro itself.Thanks for the report - seems like a legitimate expectation that discovery should mirror Babel's - or at least support
.cjs.- added and removedNeeds: ReproThis issue could be improved with a clear list of steps to reproduce the issue.This issue could be improved with a clear list of steps to reproduce the issue.
on Sep 14, 2026 Warning
Could not parse version: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.76.2.
Warning
Could not parse version: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.76.2.
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
This issue is waiting for author's feedback since 24 days. Please provide the requested feedback or this will be closed in 7 days.
- addedStaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.and removedStaleThere has been a lack of activity on this issue and it may be closed soon.There has been a lack of activity on this issue and it may be closed soon.
on Oct 9, 2026
Description
The
@react-native/metro-babel-transformerdoesn't recognize.cjsbabel config files, which causes silent failures when projects use"type": "module"in their package.json.Problem
In @react-native/metro-babel-transformer/src/index.js (lines 74-88), the transformer only searches for:
When a project has "type": "module" in package.json:
This causes hard-to-debug issues. In my case, the react-native-worklets/plugin wasn't being applied, resulting in runtime errors like "Failed to create a worklet" with no indication that the babel config wasn't being loaded.
Expected behavior
Metro should also search for:
This aligns with Babel's own configuration file resolution which supports .cjs extensions.
Workaround
Use extendsBabelConfigPath in Metro config:
// metro.config.cjs
Environment
React Native: 0.81.5
Node.js: 24.x
pnpm monorepo with "type": "module" in package.json